Terms&Conditions fixes:

* adding hints (no-store, no-copy) on xmpp messages
* frontend will ignore any archived message
This commit is contained in:
John Livingston 2024-07-05 14:57:59 +02:00
parent 914de79400
commit 9b1f24eafe
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
3 changed files with 17 additions and 2 deletions

View File

@ -36,6 +36,11 @@ converse.plugins.add('livechat-converse-terms', {
console.error('Invalid x-livechat-terms type: ', type)
return
}
if (attrs.is_archived) {
// This should not happen, as we add some no-store hints. But, just in case.
console.info('Dropping an archived x-livechat-terms message')
return
}
// console.info('Received a x-livechat-terms message', attrs)
const options = {}
options['x_livechat_terms_' + type] = attrs

View File

@ -32,8 +32,10 @@ local function create_terms_message(room, type, terms)
id = id.medium()
}, terms)
:tag('x-livechat-terms', { type = type }):up() -- adding a custom tag to specify that it is a "terms" message, so that frontend can display it with a special template.
:tag("delay", { xmlns = "urn:xmpp:delay", from = from, stamp = datetime.datetime() }):up(); -- adding a delay to trick the moderation bot (see below)
:tag("delay", { xmlns = "urn:xmpp:delay", from = from, stamp = datetime.datetime() }):up() -- adding a delay to trick the moderation bot (see below)
:tag("no-copy", { xmlns = "urn:xmpp:hints" }):up()
:tag("no-store", { xmlns = "urn:xmpp:hints" }):up()
:tag("no-permanent-store", { xmlns = "urn:xmpp:hints" }):up();
-- concerning the delay tag:
-- We are sending message to rooms from non-existant occupants.
-- If the message contains something that should be moderated by the livechat moderation bot,

View File

@ -25,6 +25,9 @@ Here is an example of sent messages:
<x-livechat-terms type="global" />
<delay xmlns="urn:xmpp:delay" stamp="2024-06-25T11:02:25Z" />
<stanza-id by="8df24108-6e70-4fc8-b1cc-f2db7fcdd535@room.p1.localhost" xmlns="urn:xmpp:sid:0" id="InoL5fonvOoR8X9gOlAYsz_N" />
<no-copy xmlns='urn:xmpp:hints'/>
<no-store xmlns='urn:xmpp:hints'/>
<no-permanent-store xmlns='urn:xmpp:hints'/>
</message>
<message xmlns="jabber:client" id="_iRSEs061gi5GBjF7zGh7f-M" type="groupchat" to="root@p1.localhost/QH1H89H1" from="8df24108-6e70-4fc8-b1cc-f2db7fcdd535@room.p1.localhost/Peertube">
@ -32,6 +35,9 @@ Here is an example of sent messages:
<x-livechat-terms type="muc" />
<delay xmlns="urn:xmpp:delay" stamp="2024-06-25T11:02:25Z" />
<stanza-id by="8df24108-6e70-4fc8-b1cc-f2db7fcdd535@room.p1.localhost" xmlns="urn:xmpp:sid:0" id="InoL5fonvOoR8X9gOlAYsz_N" />
<no-copy xmlns='urn:xmpp:hints'/>
<no-store xmlns='urn:xmpp:hints'/>
<no-permanent-store xmlns='urn:xmpp:hints'/>
</message>
```
@ -47,6 +53,8 @@ We must do so, because without nickname, some XMPP clients won't show the messag
We also add a `delay` tag, to trick the moderation bot (see comments in code).
This also ensure clients will not drop the message because there is no occupant with this name.
We also add some `urn:xmpp:hints` to avoid storing or copying these messages.
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.