-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmod_frozen_nick.lua
37 lines (29 loc) · 1.32 KB
/
mod_frozen_nick.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--- Stop users from changing nick (display name) if name is 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");