Skip to content

Commit

Permalink
feat(prosody): Updates checks in presence_identity avoids setting mis…
Browse files Browse the repository at this point in the history
…sing user.
  • Loading branch information
damencho committed Feb 11, 2025
1 parent ae98364 commit dc90851
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
13 changes: 5 additions & 8 deletions resources/prosody-plugins/mod_presence_identity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions resources/prosody-plugins/util.lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit dc90851

Please sign in to comment.