From b0fee21b01708880373556f805a7c5910646761a Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 3 Apr 2022 23:59:21 +0200 Subject: [PATCH] cleaned up --- inc/config.php | 3 ++- post.php | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/inc/config.php b/inc/config.php index 0b38662b..1b80cd22 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1828,7 +1828,8 @@ // $config['matrix'] = array( // 'access_token' => 'ACCESS_TOKEN', // 'room_id' => '%21askjdlkajsdlka:matrix.org', - // 'host' => 'https://matrix.org' + // 'host' => 'https://matrix.org', + // 'max_message_length' => 240 // ); //Securimage captcha diff --git a/post.php b/post.php index f326141e..c9631d5f 100644 --- a/post.php +++ b/post.php @@ -391,16 +391,18 @@ function handle_report(){ if(isset($config['matrix'])){ - $trimmed_post = strlen($thread['body_nomarkup']) > 280 ? '[...]' : ''; - $postcontent = mb_substr($thread['body_nomarkup'], 0, 280) . $trimmed_post; $reported_post_url = $config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ( $thread['thread'] ? $thread['thread'] : $id ) . ".html"; - $matrix_message = $reported_post_url . ($thread['thread'] ? '#' . $id : '') . " \nReason:\n" . $reason . " \nPost:\n" . $postcontent . " \n"; $post_url = $config['matrix']['host'] . "/_matrix/client/r0/rooms/" . $config['matrix']['room_id'] . "/send/m.room.message?access_token=" . $config['matrix']['access_token']; - $ch = curl_init($post_url); + + $trimmed_post = strlen($thread['body_nomarkup']) > 480 ? ' [...]' : ''; + $postcontent = mb_substr($thread['body_nomarkup'], 0, 480) . $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);