Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(displayname): Adds new feature name-readonly.
damencho5de69d501d38
diff --git a/resources/prosody-plugins/mod_muc_displayname.lua b/resources/prosody-plugins/mod_muc_displayname.luaindex 288a459cd0..33d87a5bd1 100644--- a/resources/prosody-plugins/mod_muc_displayname.lua+++ b/resources/prosody-plugins/mod_muc_displayname.lua@@ -12,6 +12,7 @@ local get_room_by_name_and_subdomain = util.get_room_by_name_and_subdomain;local is_admin = util.is_admin;local ends_with = util.ends_with;local internal_room_jid_match_rewrite = util.internal_room_jid_match_rewrite;+local NICK_NS = 'http://jabber.org/protocol/nick';-- we need to get the shared resource for joining moderators, as participants are marked as moderators-- after joining which is after the filter for stanza/out, but we need to know will this participant be a moderator@@ -42,8 +43,41 @@ function filter_stanza_out(stanza, session)endend+-- When a participant has a name-readonly feature enabled, we need to ensure that the+-- nick element in the presence stanza is set to the user's name, if it exists.+-- If the user does not have a name, we remove the nick element.+-- This is to ensure that the name is not changed by the user, as it is read-only.+function filter_stanza_in(stanza, session)+ if not session or not session.jitsi_meet_context_features+ or session.jitsi_meet_context_features['name-readonly'] ~= true then+ -- if the name-readonly feature is not set, there is nothing we need to do+ return stanza;+ end++ if stanza.name ~= 'presence' or stanza.attr.type == 'error'+ or stanza.attr.type == 'unavailable' or ends_with(stanza.attr.from, '/focus') then+ return stanza;+ end++ -- if the user does not have a name in token and name is readonly, remove any nick element+ if not session.jitsi_meet_context_user or not session.jitsi_meet_context_user.name then+ stanza:remove_children('nick', NICK_NS);+ return stanza;+ end++ local nick_element = stanza:get_child('nick', NICK_NS);++ if nick_element:get_text() ~= session.jitsi_meet_context_user.name then+ stanza:remove_children('nick', NICK_NS);+ stanza:tag('nick', { xmlns = NICK_NS }):text(session.jitsi_meet_context_user.name):up();+ end++ return stanza;+end+function filter_session(session)filters.add_filter(session, 'stanzas/out', filter_stanza_out, -100);+ filters.add_filter(session, 'stanzas/in', filter_stanza_in, -100);endfunction module.load()