Skip to content

Commit

Permalink
add a prosody module to insert identity information (when available) … (
Browse files Browse the repository at this point in the history
jitsi#2627)

* add a prosody module to insert identity information (when available) into
presence

prosody will check for jitsi_meet_context_user and
jitsi_meet_context_group in the session and, if they are present, insert
them into presence (we do this in prosody so they cannot be spoofed).

* remove unused 'presence' variable

* refactor to modify presence message in place

* make object member access consistent

* make the group information optional
  • Loading branch information
bbaldino authored and damencho committed Mar 20, 2018
1 parent 309fcf9 commit fef1d8b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions resources/prosody-plugins/mod_presence_identity.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
local stanza = require "util.stanza";

-- For all received presence messages, if the jitsi_meet_context_(user|group)
-- 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
-- First remove any 'identity' element if it already
-- exists
event.stanza:maptags(
function(tag)
for k, v in pairs(tag) do
if k == "name" and v == "identity" then
return nil
end
end
return tag
end
)
module:log("debug", "Presence after previous identity stripped: %s", tostring(event.stanza))

event.stanza:tag("identity"):tag("user")
for k, v in pairs(event.origin.jitsi_meet_context_user) do
event.stanza:tag(k):text(v):up()
end
event.stanza:up()

-- Add the group information if it is present
if event.origin.jitsi_meet_context_group then
event.stanza:tag("group"):text(event.origin.jitsi_meet_context_group)
end

module:log("debug", "Sending presence with identity inserted %s", tostring(event.stanza))
end
end
end

module:hook("pre-presence/bare", on_message);
module:hook("pre-presence/full", on_message);

0 comments on commit fef1d8b

Please sign in to comment.