changeset 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
files mod_muc_bot/mod_muc_bot.lua
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_bot/mod_muc_bot.lua	Thu Apr 01 13:15:05 2021 +0200
+++ b/mod_muc_bot/mod_muc_bot.lua	Sat Apr 10 19:20:03 2021 +0200
@@ -24,14 +24,13 @@
 			return true;
 		end
 
+		local occupant = room:new_occupant(module.host, virtual_occupant_jid);
+		local join = st.presence({from = event.from; to = virtual_occupant_jid});
+		local dest_x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"});
+		occupant:set_session(event.from, join, true);
 		-- Inject virtual occupant to trick all the other hooks on this event that
 		-- this is an actual legitimate participant.
-		-- XXX Hack!
-		event.occupant = {
-			nick = virtual_occupant_jid;
-			bare_jid = jid.bare(event.from);
-			role = "participant";
-		};
+		event.occupant = occupant;
 
 	end
 end, 66);