From 57ec54c3a7d077fa8436245321da8af3b6052af9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 3 Apr 2022 23:37:00 +0200 Subject: [PATCH] report function fix --- inc/config.php | 7 +++++++ post.php | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/inc/config.php b/inc/config.php index c5fa69d9..0b38662b 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1824,6 +1824,13 @@ * ==================== */ + // Matrix integration for reports + // $config['matrix'] = array( + // 'access_token' => 'ACCESS_TOKEN', + // 'room_id' => '%21askjdlkajsdlka:matrix.org', + // 'host' => 'https://matrix.org' + // ); + //Securimage captcha //Note from lainchan PR: "TODO move a bunch of things here" diff --git a/post.php b/post.php index e035143e..a1d50a55 100644 --- a/post.php +++ b/post.php @@ -391,9 +391,16 @@ function handle_report(){ if(isset($config['matrix'])){ - $ch = curl_init("$config['matrix']['host']/_matrix/client/r0/rooms/$config['matrix']['room_id']/send/m.room.message?access_token=$config['matrix']['access_token']"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $slackmessage); - $result = curl_exec($ch); + $slackmessage = $config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ( $thread['thread'] ? $thread['thread'] : $id ) . ".html" . ($thread['thread'] ? '#' . $id : '') . ' \\n ' . $reason . '\\n ' . $postcontent . ' \\n '; + $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($url); + $post_data = json_encode(array( + "msgtype" => "m.text", + "body" => $slackmessage + )); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $postResult = curl_exec($ch); curl_close($ch); } }