add a prosody module to insert identity information (when available) … (#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
This commit is contained in:
parent
309fcf9672
commit
fef1d8b520
|
@ -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);
|
Loading…
Reference in New Issue