From 7b8ed08e881da531f68f425db8f50b0c1943e5ac Mon Sep 17 00:00:00 2001 From: LDA Date: Sun, 13 Apr 2025 10:39:15 +0000 Subject: [PATCH] [ADD] Optionally allow instance admins to ignore m.notice events --- CHANGELOG.md | 2 ++ README.MD | 2 +- src/MatrixEventHandler.c | 8 ++++++++ src/Parsee/Config.c | 2 ++ src/include/Parsee.h | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b12530..f4ffcde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ TBD - The endpoint for media has been changed to '/media/[SERV]/[ID]?hmac=...' - Add parsee-plumb tool to manage plumbing from outside Parsee if it is not running. - Add packaging for Guix (see #18) +- Parsee is now dependent on authenticated media to function. + (Please, Matrix, do _not_ touch anything, I do _not_ want to mess with this anymore) #### Bugfixes - Fix potential infinite loops when processing some messages. - Parsee now handles pinging puppets from Matrix more sanely. diff --git a/README.MD b/README.MD index ee223de..f9522e8 100644 --- a/README.MD +++ b/README.MD @@ -22,7 +22,7 @@ Please scream at me if that fails(or just doesn't run on a overclocked Raspberry ### "Why not just use Matrix lol" ### "Why not just use XMPP lol" -These two having the same answer should be enough information. Also can I *just* have fun? +These two having the same answer should be enough information. One could also argue that both sides need to migrate(onboard) the other side, so a bridge may be a good way to start. diff --git a/src/MatrixEventHandler.c b/src/MatrixEventHandler.c index 17a3bb9..638b5a3 100644 --- a/src/MatrixEventHandler.c +++ b/src/MatrixEventHandler.c @@ -367,6 +367,7 @@ ParseeMessageHandler(ParseeData *data, HashMap *event) DbRef *ref = NULL; HashMap *json = NULL; + char *msgtype = GrabString(event, 2, "content", "msgtype"); char *m_sender = GrabString(event, 1, "sender"); char *unedited_id = NULL; char *body = GrabString(event, 2, "content", "body"); @@ -391,6 +392,13 @@ ParseeMessageHandler(ParseeData *data, HashMap *event) if (new_content) body = new_content; } + if (data->config->ignore_bots && StrEquals(msgtype, "m.notice")) + { + Free(reply_id); + Free(xepd); + Free(unedited_id); + return; + } if (ParseeIsPuppet(data->config, m_sender) || ParseeManageBan(data, m_sender, id)) { diff --git a/src/Parsee/Config.c b/src/Parsee/Config.c index 45e6fe5..b95e5e1 100644 --- a/src/Parsee/Config.c +++ b/src/Parsee/Config.c @@ -85,6 +85,8 @@ ParseeConfigLoad(char *conf) config->max_stanza_size = 10000; } + CopyToBool(ignore_bots, "ignore_bots"); + CopyToStr(media_base, "media_base"); CopyToStr(db_path, "db"); diff --git a/src/include/Parsee.h b/src/include/Parsee.h index ea5d18b..4b1f7aa 100644 --- a/src/include/Parsee.h +++ b/src/include/Parsee.h @@ -44,6 +44,7 @@ typedef struct ParseeConfig { int homeserver_tls; bool accept_pings; + bool ignore_bots; /* ------- JABBER -------- */