summaryrefslogtreecommitdiff
path: root/post.php
diff options
context:
space:
mode:
authorBenjamin Southall <applemansigloo@gmail.com>2016-12-14 06:11:54 +0900
committerBenjamin Southall <applemansigloo@gmail.com>2016-12-14 06:11:54 +0900
commit5feae402cb55d49963bfd2c6f5a33d10690ecbc1 (patch)
tree2954153dd49f616f5018490058ff4bfbd17300d3 /post.php
parent1cab6af5263a943230c86962779913d53e2df0c9 (diff)
Changes to report notification callback to Slack HTTP endpoint
Diffstat (limited to 'post.php')
-rw-r--r--post.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/post.php b/post.php
index 84858bb2..bbd0c628 100644
--- a/post.php
+++ b/post.php
@@ -1147,6 +1147,37 @@ if (isset($_POST['delete'])) {
$query->bindValue(':thread', $post['thread']);
$query->bindValue(':limit', $config['cycle_limit'], PDO::PARAM_INT);
$query->execute() or error(db_error($query));
+ if ($config['slack'])
+ {
+ function slack($message, $room = "reports", $icon = ":no_entry_sign:")
+ {
+ $room = ($room) ? $room : "reports";
+ $data = "payload=" . json_encode(array(
+ "channel" => "#{$room}",
+ "text" => urlencode($message),
+ "icon_emoji" => $icon
+ ));
+
+ // You can get your webhook endpoint from your Slack settings
+ // For some reason using the configuration key doesn't work
+ $ch = curl_init($config['slack_incoming_webhook_endpoint']);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ $result = curl_exec($ch);
+ curl_close($ch);
+
+ return $result;
+ }
+
+ $postcontent = mb_substr($thread['body_nomarkup'], 0, 120) . '... _*(POST TRIMMED)*_';
+ $slackmessage = '<' .$config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ( $thread['thread'] ? $thread['thread'] : $id ) . ".html" . ($thread['thread'] ? '#' . $id : '') . '> \n ' . $reason . '\n ' . $postcontent . '\n';
+
+ $slackresult = slack($slackmessage, $config['slack_channel']);
+ }
+
+
}
if (isset($post['antispam_hash'])) {