Mercurial > prosody-modules
annotate mod_smacks_noerror/mod_smacks_noerror.lua @ 3656:3e0f4d727825
mod_vcard_muc: Add an alternative method of signaling avatar change
When the avatar has been changed, a signal is sent that the room
configuration has changed. Clients then do a disco#info query to find
the SHA-1 of the new avatar. They can then fetch it as before, or not if
they have it cached already.
This is meant to be less disruptive than signaling via presence, which
caused problems for some clients.
If clients transition to the new method, the old one can eventually be removed.
The namespace is made up while waiting for standardization.
Otherwise it is very close to what's described in
https://xmpp.org/extensions/inbox/muc-avatars.html
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 25 Aug 2019 20:46:43 +0200 |
| parents | f35b2b76df6d |
| children | e7dc25e54d02 |
| rev | line source |
|---|---|
|
2392
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
1 local t_insert = table.insert; |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
2 |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
3 local mod_smacks = module:depends"smacks" |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
4 |
|
3171
f35b2b76df6d
mod_smacks_noerror: Add ability to silence errors if mod_offline is disabled
tmolitor <thilo@eightysoft.de>
parents:
2392
diff
changeset
|
5 -- ignore offline messages and don't return any error (the message will be already in MAM at this point) |
|
f35b2b76df6d
mod_smacks_noerror: Add ability to silence errors if mod_offline is disabled
tmolitor <thilo@eightysoft.de>
parents:
2392
diff
changeset
|
6 -- this is *only* triggered if mod_offline is *not* loaded and completely ignored otherwise |
|
f35b2b76df6d
mod_smacks_noerror: Add ability to silence errors if mod_offline is disabled
tmolitor <thilo@eightysoft.de>
parents:
2392
diff
changeset
|
7 module:hook("message/offline/handle", function(event) |
|
f35b2b76df6d
mod_smacks_noerror: Add ability to silence errors if mod_offline is disabled
tmolitor <thilo@eightysoft.de>
parents:
2392
diff
changeset
|
8 event.origin.log("debug", "Ignoring offline message (mod_offline seems to be *not* loaded)..."); |
|
f35b2b76df6d
mod_smacks_noerror: Add ability to silence errors if mod_offline is disabled
tmolitor <thilo@eightysoft.de>
parents:
2392
diff
changeset
|
9 return true; |
|
f35b2b76df6d
mod_smacks_noerror: Add ability to silence errors if mod_offline is disabled
tmolitor <thilo@eightysoft.de>
parents:
2392
diff
changeset
|
10 end, -100); |
|
f35b2b76df6d
mod_smacks_noerror: Add ability to silence errors if mod_offline is disabled
tmolitor <thilo@eightysoft.de>
parents:
2392
diff
changeset
|
11 |
|
2392
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
12 local function discard_unacked_messages(session) |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
13 local queue = session.outgoing_stanza_queue; |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
14 local replacement_queue = {}; |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
15 session.outgoing_stanza_queue = replacement_queue; |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
16 |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
17 for _, stanza in ipairs(queue) do |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
18 if stanza.name == "message" and stanza.attr.xmlns == nil and |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
19 ( stanza.attr.type == "chat" or ( stanza.attr.type or "normal" ) == "normal" ) then |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
20 -- do nothing here for normal messages and don't send out "message delivery errors", |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
21 -- because messages are already in MAM at this point (no need to frighten users) |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
22 else |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
23 t_insert(replacement_queue, stanza); |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
24 end |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
25 end |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
26 end |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
27 |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
28 local handle_unacked_stanzas = mod_smacks.handle_unacked_stanzas; |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
29 |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
30 mod_smacks.handle_unacked_stanzas = function (session) |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
31 -- Only deal with authenticated (c2s) sessions |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
32 if session.username then |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
33 discard_unacked_messages(session) |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
34 end |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
35 return handle_unacked_stanzas(session); |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
36 end |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
37 |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
38 function module.unload() |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
39 mod_smacks.handle_unacked_stanzas = handle_unacked_stanzas; |
|
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
40 end |
