From a0af981292433725be120cb5200468c0e8997dfb Mon Sep 17 00:00:00 2001
From: echicken <echicken@bbs.electronicchicken.com>
Date: Thu, 8 Oct 2020 00:32:45 -0400
Subject: [PATCH] If user is sysop, send a block-sender button back with the
 getMailBody data. Use xjs_eval() to render said button. Added addTwit method.
 Nothing fancy, just adds your string to twitlist.cfg and assumes you were
 really careful about producing said string and that it won't destroy the
 universe.

---
 webv4/lib/forum.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/webv4/lib/forum.js b/webv4/lib/forum.js
index 9dcf3cca65..069bcd112a 100644
--- a/webv4/lib/forum.js
+++ b/webv4/lib/forum.js
@@ -1,4 +1,5 @@
 require('sbbsdefs.js', 'MSG_DELETE');
+require('xjs.js', 'xjs_compile');
 load(settings.web_lib + 'mime-decode.js');
 
 function listGroups() {
@@ -404,10 +405,25 @@ function getMailBody(number) {
     ret.body = formatMessage(pt_body == body ? decoded.body : pt_body); // See above re: pt_body
     ret.inlines = decoded.inlines;
     ret.attachments = decoded.attachments;
+    if (user.is_sysop) {
+        ret.buttons = [
+            format(xjs_eval(settings.web_components + 'twit-button.xjs', true), number, number, header.from, header.from_net_addr),
+        ];
+    }
 
     return ret;
 }
 
+function addTwit(str) {
+    const f = new File(system.ctrl_dir + 'twitlist.cfg');
+    if (!f.open('a')) {
+        log(LOG_ERR, 'Failed to add ' + str + ' to twitlist');
+        return;
+    }
+    f.writeln(str);
+    f.close();
+}
+
 // Returns the user's signature, or an empty String
 function getSignature() {
     var fn = format('%s/user/%04d.sig', system.data_dir, user.number);
-- 
GitLab