From 96270c5ac5b44c5a3cadfab33987cee62bd305fa Mon Sep 17 00:00:00 2001 From: John Livingston Date: Thu, 22 Feb 2024 10:19:51 +0100 Subject: [PATCH] Slow Mode Fix: ignore messages without body. --- prosody-modules/mod_muc_slow_mode/mod_muc_slow_mode.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/prosody-modules/mod_muc_slow_mode/mod_muc_slow_mode.lua b/prosody-modules/mod_muc_slow_mode/mod_muc_slow_mode.lua index 8a81d21e..27ad0c11 100644 --- a/prosody-modules/mod_muc_slow_mode/mod_muc_slow_mode.lua +++ b/prosody-modules/mod_muc_slow_mode/mod_muc_slow_mode.lua @@ -86,6 +86,13 @@ function handle_groupchat(event) local origin, stanza = event.origin, event.stanza; local room = event.room; + -- only consider messages with body (ie: ignore chatstate and other non-text xmpp messages) + local body = stanza:get_child_text("body") + if not body or #body < 1 then + -- module:log("debug", "No body, message accepted"); + return; + end + local duration = get_slow_mode_duration(room) or 0; if duration <= 0 then -- no slow mode for this room @@ -143,7 +150,6 @@ function handle_groupchat(event) ); -- Note: following commented lines were inspired by mod_muc_limits, but it seems it is not required. - -- local body = stanza:get_child_text("body"); -- if body then -- reply:up():tag("body"):text(body):up(); -- end