# HG changeset patch # User Matthew Wild # Date 1608029351 0 # Node ID 3f3b672b7616d2a8a8158e0d3ff6518177afbece # Parent 8006da2cf44c4956b5a18f5408b9be85bc79ae57 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. diff -r 8006da2cf44c -r 3f3b672b7616 mod_vcard_muc/mod_vcard_muc.lua --- 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)