diff --git a/resources/prosody-plugins/mod_presence_identity.lua b/resources/prosody-plugins/mod_presence_identity.lua index 4db397e841f4..44d863439a69 100644 --- a/resources/prosody-plugins/mod_presence_identity.lua +++ b/resources/prosody-plugins/mod_presence_identity.lua @@ -5,16 +5,13 @@ local update_presence_identity = module:require "util".update_presence_identity; -- values are set in the session, then insert them into the presence messages -- for that session. function on_message(event) - if event and event["stanza"] then - if event.origin and event.origin.jitsi_meet_context_user then - + local stanza, session = event.stanza, event.origin; + if stanza and session then update_presence_identity( - event.stanza, - event.origin.jitsi_meet_context_user, - event.origin.jitsi_meet_context_group + stanza, + session.jitsi_meet_context_user, + session.jitsi_meet_context_group ); - - end end end diff --git a/resources/prosody-plugins/util.lib.lua b/resources/prosody-plugins/util.lib.lua index e6bf7022da78..e37bc2459e7b 100644 --- a/resources/prosody-plugins/util.lib.lua +++ b/resources/prosody-plugins/util.lib.lua @@ -208,8 +208,7 @@ end -- @param creator_group the group of the user who created the user which -- presence we are updating (this is the poltergeist case, where a user creates -- a poltergeist), optional. -function update_presence_identity( - stanza, user, group, creator_user, creator_group) +function update_presence_identity(stanza, user, group, creator_user, creator_group) -- First remove any 'identity' element if it already -- exists, so it cannot be spoofed by a client @@ -222,7 +221,11 @@ function update_presence_identity( end return tag end - ) + ); + + if not user then + return; + end stanza:tag("identity"):tag("user"); for k, v in pairs(user) do