Software /
code /
prosody
Comparison
plugins/mod_blocklist.lua @ 8275:13dad833e821
mod_blocklist: Drop messages to existing full JIDs in order to prevent issues with MUC PMs, fixes #690
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 27 Sep 2017 15:27:29 +0200 |
parent | 8040:62c540d51d50 |
child | 8741:0fd63ed1f647 |
comparison
equal
deleted
inserted
replaced
8274:3798955049e3 | 8275:13dad833e821 |
---|---|
20 local jid_prep = require"util.jid".prep; | 20 local jid_prep = require"util.jid".prep; |
21 local jid_split = require"util.jid".split; | 21 local jid_split = require"util.jid".split; |
22 | 22 |
23 local storage = module:open_store(); | 23 local storage = module:open_store(); |
24 local sessions = prosody.hosts[module.host].sessions; | 24 local sessions = prosody.hosts[module.host].sessions; |
25 local full_sessions = prosody.full_sessions; | |
25 | 26 |
26 -- First level cache of blocklists by username. | 27 -- First level cache of blocklists by username. |
27 -- Weak table so may randomly expire at any time. | 28 -- Weak table so may randomly expire at any time. |
28 local cache = setmetatable({}, { __mode = "v" }); | 29 local cache = setmetatable({}, { __mode = "v" }); |
29 | 30 |
269 end | 270 end |
270 return drop_stanza(event); -- result or error | 271 return drop_stanza(event); -- result or error |
271 end | 272 end |
272 | 273 |
273 local function bounce_message(event) | 274 local function bounce_message(event) |
274 local type = event.stanza.attr.type; | 275 local stanza = event.stanza; |
276 local type = stanza.attr.type; | |
275 if type == "chat" or not type or type == "normal" then | 277 if type == "chat" or not type or type == "normal" then |
278 if full_sessions[stanza.attr.to] then | |
279 -- See #690 | |
280 return drop_stanza(event); | |
281 end | |
276 return bounce_stanza(event); | 282 return bounce_stanza(event); |
277 end | 283 end |
278 return drop_stanza(event); -- drop headlines, groupchats etc | 284 return drop_stanza(event); -- drop headlines, groupchats etc |
279 end | 285 end |
280 | 286 |
303 -- Hook all the events! | 309 -- Hook all the events! |
304 local prio_in, prio_out = 100, 100; | 310 local prio_in, prio_out = 100, 100; |
305 module:hook("presence/bare", drop_stanza, prio_in); | 311 module:hook("presence/bare", drop_stanza, prio_in); |
306 module:hook("presence/full", drop_stanza, prio_in); | 312 module:hook("presence/full", drop_stanza, prio_in); |
307 | 313 |
308 -- FIXME See #690 | |
309 module:hook("message/bare", bounce_message, prio_in); | 314 module:hook("message/bare", bounce_message, prio_in); |
310 module:hook("message/full", bounce_message, prio_in); | 315 module:hook("message/full", bounce_message, prio_in); |
311 | 316 |
312 module:hook("iq/bare", bounce_iq, prio_in); | 317 module:hook("iq/bare", bounce_iq, prio_in); |
313 module:hook("iq/full", bounce_iq, prio_in); | 318 module:hook("iq/full", bounce_iq, prio_in); |