Mercurial > prosody-modules
annotate mod_smacks_noerror/mod_smacks_noerror.lua @ 3046:d0db28768980
mod_vcard_muc: Send presence on muc-occupant-session-new event
author | Michel Le Bihan <michel@lebihan.pl> |
---|---|
date | Sat, 26 May 2018 10:58:06 +0200 |
parents | d1e975c24545 |
children | f35b2b76df6d |
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 |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
5 local function discard_unacked_messages(session) |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
6 local queue = session.outgoing_stanza_queue; |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
7 local replacement_queue = {}; |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
8 session.outgoing_stanza_queue = replacement_queue; |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
9 |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
10 for _, stanza in ipairs(queue) do |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
11 if stanza.name == "message" and stanza.attr.xmlns == nil and |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
12 ( 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
|
13 -- 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
|
14 -- 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
|
15 else |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
16 t_insert(replacement_queue, stanza); |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
17 end |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
18 end |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
19 end |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
20 |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
21 local handle_unacked_stanzas = mod_smacks.handle_unacked_stanzas; |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
22 |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
23 mod_smacks.handle_unacked_stanzas = function (session) |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
24 -- Only deal with authenticated (c2s) sessions |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
25 if session.username then |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
26 discard_unacked_messages(session) |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
27 end |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
28 return handle_unacked_stanzas(session); |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
29 end |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
30 |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
31 function module.unload() |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
32 mod_smacks.handle_unacked_stanzas = handle_unacked_stanzas; |
d1e975c24545
mod_smacks_noerror: Initial commit
tmolitor <thilo@eightysoft.de>
parents:
diff
changeset
|
33 end |