From cad2eef7afc2cb5df9daf35a1abe59dc9a4db860 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Thu, 27 Jun 2024 15:14:49 +0200 Subject: [PATCH] Fix terms: broadcasted messages should not be stored by mod_muc_mam. --- .../mod_muc_peertubelivechat_terms.lua | 8 ++++++++ support/documentation/content/en/technical/terms.md | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/prosody-modules/mod_muc_peertubelivechat_terms/mod_muc_peertubelivechat_terms.lua b/prosody-modules/mod_muc_peertubelivechat_terms/mod_muc_peertubelivechat_terms.lua index 11daf5eb..cdb6ebf7 100644 --- a/prosody-modules/mod_muc_peertubelivechat_terms/mod_muc_peertubelivechat_terms.lua +++ b/prosody-modules/mod_muc_peertubelivechat_terms/mod_muc_peertubelivechat_terms.lua @@ -116,3 +116,11 @@ module:hook("muc-occupant-groupchat", function(event) return child; end); end, 100); + +-- don't save terms messages in history +module:hook("muc-message-is-historic", function(event) + local stanza = event.stanza; + if (stanza:get_child("x-livechat-terms")) then + return false, "hint"; + end +end, 1); diff --git a/support/documentation/content/en/technical/terms.md b/support/documentation/content/en/technical/terms.md index eecd4365..9c23217c 100644 --- a/support/documentation/content/en/technical/terms.md +++ b/support/documentation/content/en/technical/terms.md @@ -49,6 +49,10 @@ This also ensure clients will not drop the message because there is no occupant When muc terms are updated, the new terms will be broadcasted. +To avoid anyone spoofing terms & conditions, incoming message stanza are filtered, and any `x-livechat-terms` tag will be removed. + +Message history is disabled for message containing the `x-livechat-terms`, so that messages broadcasted when the terms change are not stored by muc_mam modume ("Message Archiving Management"). + ## Frontend For standard XMPP clients, terms will be shown as delayed messages.