Mercurial > prosody-modules
comparison mod_muc_batched_probe/mod_muc_batched_probe.lua @ 4188:4611999fd8d3
mod_muc_batched_probe: don't rely on mt_room:respond_to_probe method
That method assumes it's responding to a `<presence>` stanza, which breaks for
the bached probe use-case.
author | JC Brand <jc@opkode.com> |
---|---|
date | Mon, 12 Oct 2020 13:21:16 +0200 |
parents | 845d13ab0dc0 |
children | e06258fc6cf1 |
comparison
equal
deleted
inserted
replaced
4187:e2db07017332 | 4188:4611999fd8d3 |
---|---|
20 local query = stanza:get_child("query", "http://jabber.org/protocol/muc#user"); | 20 local query = stanza:get_child("query", "http://jabber.org/protocol/muc#user"); |
21 if not query then | 21 if not query then |
22 return; | 22 return; |
23 end; | 23 end; |
24 | 24 |
25 local origin = event.origin; | |
25 local room = get_room_from_jid(stanza.attr.to); | 26 local room = get_room_from_jid(stanza.attr.to); |
27 local probing_occupant = room:get_occupant_by_real_jid(stanza.attr.from); | |
28 if probing_occupant == nil then | |
29 origin.send(st.error_reply(stanza, "cancel", "not-acceptable", "You are not currently connected to this chat", room.jid)); | |
30 return true; | |
31 end | |
32 | |
26 for item in query:children() do | 33 for item in query:children() do |
27 local probed_jid = item.attr.jid; | 34 local probed_jid = item.attr.jid; |
28 room:respond_to_probe(stanza.attr.from, probed_jid); | 35 local probed_occupant = room:get_occupant_by_nick(probed_jid); |
36 if probed_occupant == nil then | |
37 local pr = room:build_unavailable_presence(probed_jid, stanza.attr.from); | |
38 if pr then | |
39 room:route_stanza(pr); | |
40 end | |
41 return; | |
42 end | |
43 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}); | |
44 room:publicise_occupant_status(probed_occupant, x, nil, nil, nil, nil, false, probing_occupant); | |
45 | |
29 end | 46 end |
30 event.origin.send(st.reply(stanza)); | 47 origin.send(st.reply(stanza)); |
31 return true; | 48 return true; |
32 end | 49 end |
33 | 50 |
34 | 51 |
35 module:hook("iq/bare", respondToBatchedProbe, 1); | 52 module:hook("iq/bare", respondToBatchedProbe, 1); |