mod_vcard_muc/mod_vcard_muc.lua
changeset 4304 3f3b672b7616
parent 4047 a533abe6ffd0
child 5294 dddac5a3f447
--- a/mod_vcard_muc/mod_vcard_muc.lua	Tue Dec 15 11:26:29 2020 +0100
+++ b/mod_vcard_muc/mod_vcard_muc.lua	Tue Dec 15 10:49:11 2020 +0000
@@ -39,11 +39,9 @@
 
 end
 
-local function broadcast_presence(room_jid, to)
-	local room = get_room_from_jid(room_jid);
-
+local function broadcast_presence(room, to)
 	local photo_hash = get_photo_hash(room);
-	local presence_vcard = st.presence({to = to, from = room_jid})
+	local presence_vcard = st.presence({to = to, from = room.jid})
 		:tag("x", { xmlns = "vcard-temp:x:update" })
 			:tag("photo"):text(photo_hash):up();
 
@@ -81,7 +79,7 @@
 		if from_affiliation == "owner" then
 			if vcards:set(room_node, st.preserialize(stanza.tags[1])) then
 				session.send(st.reply(stanza):tag("vCard", { xmlns = "vcard-temp" }));
-				broadcast_presence(room_jid, nil)
+				broadcast_presence(room, nil)
 
 				room:broadcast_message(st.message({ from = room.jid, type = "groupchat" })
 					:tag("x", { xmlns = "http://jabber.org/protocol/muc#user" })
@@ -112,5 +110,5 @@
 end);
 
 module:hook("muc-occupant-session-new", function(event)
-	broadcast_presence(event.room.jid, event.jid);
+	broadcast_presence(event.room, event.jid);
 end)