Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

add a prosody module to insert identity information (when available) … (#2627)

bbaldinofef1d8b52019
diff --git a/resources/prosody-plugins/mod_presence_identity.lua b/resources/prosody-plugins/mod_presence_identity.lua
new file mode 100644
index 0000000000..72ed00ce0f
--- /dev/null
+++ b/resources/prosody-plugins/mod_presence_identity.lua
@@ -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);