changeset 4300:3f3b672b7616

mod_vcard_muc: Pass room object around instead of JID, hopefully fixing traceback More efficient to pass the object around instead of using the JID and looking up the object when needed. It seems in some (undetermined) cases get_room_from_jid(room.jid) is nil.
author Matthew Wild <mwild1@gmail.com>
date Tue, 15 Dec 2020 10:49:11 +0000
parents 8006da2cf44c
children bcb2b9adfcde
files mod_vcard_muc/mod_vcard_muc.lua
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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)