forked from leftypol/leftypol
Matrix report integration (#74)
Enables posting reports to a matrix room. Co-authored-by: nonmakina <nonmakina@leftypol.org> Co-committed-by: nonmakina <nonmakina@leftypol.org>
This commit is contained in:
parent
2b5365b572
commit
3725d27e72
|
@ -1824,6 +1824,14 @@
|
|||
* ====================
|
||||
*/
|
||||
|
||||
// Matrix integration for reports
|
||||
// $config['matrix'] = array(
|
||||
// 'access_token' => 'ACCESS_TOKEN',
|
||||
// 'room_id' => '%21askjdlkajsdlka:matrix.org',
|
||||
// 'host' => 'https://matrix.org',
|
||||
// 'max_message_length' => 240
|
||||
// );
|
||||
|
||||
//Securimage captcha
|
||||
//Note from lainchan PR: "TODO move a bunch of things here"
|
||||
|
||||
|
|
18
post.php
18
post.php
|
@ -390,6 +390,24 @@ function handle_report(){
|
|||
}
|
||||
|
||||
|
||||
if(isset($config['matrix'])){
|
||||
$reported_post_url = $config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ( $thread['thread'] ? $thread['thread'] : $id ) . ".html";
|
||||
$post_url = $config['matrix']['host'] . "/_matrix/client/r0/rooms/" . $config['matrix']['room_id'] . "/send/m.room.message?access_token=" . $config['matrix']['access_token'];
|
||||
|
||||
$trimmed_post = strlen($thread['body_nomarkup']) > $config['matrix']['max_message_length'] ? ' [...]' : '';
|
||||
$postcontent = mb_substr($thread['body_nomarkup'], 0, $config['matrix']['max_message_length']) . $trimmed_post;
|
||||
$matrix_message = $reported_post_url . ($thread['thread'] ? '#' . $id : '') . " \nReason:\n" . $reason . " \nPost:\n" . $postcontent . " \n";
|
||||
$post_data = json_encode(array(
|
||||
"msgtype" => "m.text",
|
||||
"body" => $matrix_message
|
||||
));
|
||||
|
||||
$ch = curl_init($post_url);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$postResult = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
}
|
||||
}
|
||||
|
||||
$is_mod = isset($_POST['mod']) && $_POST['mod'];
|
||||
|
|
Loading…
Reference in New Issue
Block a user