Mercurial > prosody-modules
comparison mod_muc_bot/mod_muc_bot.lua @ 4564:d25f0fea270f
mod_muc_bot: Reduce hackyness of occupant construction
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 10 Apr 2021 19:20:03 +0200 |
parents | 30f2d7c3f946 |
children | 3b2ae854842c |
comparison
equal
deleted
inserted
replaced
4563:30f2d7c3f946 | 4564:d25f0fea270f |
---|---|
22 if not virtual_occupant_jid then | 22 if not virtual_occupant_jid then |
23 module:send(st.error_reply(event.stanza, "modify", "jid-malformed", "Nickname must pass strict validation", room.jid)); | 23 module:send(st.error_reply(event.stanza, "modify", "jid-malformed", "Nickname must pass strict validation", room.jid)); |
24 return true; | 24 return true; |
25 end | 25 end |
26 | 26 |
27 local occupant = room:new_occupant(module.host, virtual_occupant_jid); | |
28 local join = st.presence({from = event.from; to = virtual_occupant_jid}); | |
29 local dest_x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}); | |
30 occupant:set_session(event.from, join, true); | |
27 -- Inject virtual occupant to trick all the other hooks on this event that | 31 -- Inject virtual occupant to trick all the other hooks on this event that |
28 -- this is an actual legitimate participant. | 32 -- this is an actual legitimate participant. |
29 -- XXX Hack! | 33 event.occupant = occupant; |
30 event.occupant = { | |
31 nick = virtual_occupant_jid; | |
32 bare_jid = jid.bare(event.from); | |
33 role = "participant"; | |
34 }; | |
35 | 34 |
36 end | 35 end |
37 end, 66); | 36 end, 66); |
38 | 37 |
39 module:hook("muc-occupant-pre-join", function(event) | 38 module:hook("muc-occupant-pre-join", function(event) |