Skip to content

Instantly share code, notes, and snippets.

@shawnchin
Created June 9, 2021 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawnchin/221d7d9df069f00cbae1e916fd5d3501 to your computer and use it in GitHub Desktop.
Save shawnchin/221d7d9df069f00cbae1e916fd5d3501 to your computer and use it in GitHub Desktop.
Jitsi prosody plugin to stop users from changing display name if name provided by JWT
--- Stop users from changing nick (display name) if name is provided provided by jisi_meet_context_user
-- For all received presence messages, if jitsi_meet_context_user.name value is set in the session, then we simply
-- override nick with that value.
function on_message(event)
if event and event["stanza"] then
if event.origin and event.origin.jitsi_meet_context_user then
local name = event.origin.jitsi_meet_context_user['name'];
if name then
-- first, drop existing 'nick' element
event.stanza:maptags(
function(tag)
for k, v in pairs(tag) do
if k == "name" and v == "nick" then
return nil;
end
end
return tag
end
)
-- then insert new one using name from user context
event.stanza:tag("nick", { xmlns = "http://jabber.org/protocol/nick"} ):text(name):up()
module:log("debug", "Nick replaced in stanza %s", tostring(event.stanza));
end
end
end
end
module:hook("pre-presence/bare", on_message);
module:hook("pre-presence/full", on_message);
module:log("info", "loaded mod_frozen_nick");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment