|
@@ -2,24 +2,28 @@ local filters = require 'util.filters';
|
2
|
2
|
local jid = require "util.jid";
|
3
|
3
|
local jid_bare = require "util.jid".bare;
|
4
|
4
|
local jid_host = require "util.jid".host;
|
|
5
|
+local st = require "util.stanza";
|
5
|
6
|
local um_is_admin = require "core.usermanager".is_admin;
|
6
|
7
|
local util = module:require "util";
|
7
|
8
|
local is_healthcheck_room = util.is_healthcheck_room;
|
8
|
9
|
local extract_subdomain = util.extract_subdomain;
|
|
10
|
+local get_room_from_jid = util.get_room_from_jid;
|
9
|
11
|
local presence_check_status = util.presence_check_status;
|
10
|
12
|
local MUC_NS = 'http://jabber.org/protocol/muc';
|
11
|
13
|
|
12
|
14
|
local moderated_subdomains;
|
13
|
15
|
local moderated_rooms;
|
|
16
|
+local disable_revoke_owners;
|
14
|
17
|
|
15
|
18
|
local function load_config()
|
16
|
19
|
moderated_subdomains = module:get_option_set("allowners_moderated_subdomains", {})
|
17
|
20
|
moderated_rooms = module:get_option_set("allowners_moderated_rooms", {})
|
|
21
|
+ disable_revoke_owners = module:get_option_boolean("allowners_disable_revoke_owners", false);
|
18
|
22
|
end
|
19
|
23
|
load_config();
|
20
|
24
|
|
21
|
|
-local function is_admin(jid)
|
22
|
|
- return um_is_admin(jid, module.host);
|
|
25
|
+local function is_admin(_jid)
|
|
26
|
+ return um_is_admin(_jid, module.host);
|
23
|
27
|
end
|
24
|
28
|
|
25
|
29
|
-- List of the bare_jids of all occupants that are currently joining (went through pre-join) and will be promoted
|
|
@@ -71,12 +75,14 @@ module:hook("muc-occupant-pre-join", function (event)
|
71
|
75
|
end
|
72
|
76
|
|
73
|
77
|
if not (room_name == session.jitsi_meet_room or session.jitsi_meet_room == '*') then
|
74
|
|
- module:log('debug', 'skip allowners for auth user and non matching room name: %s, jwt room name: %s', room_name, session.jitsi_meet_room);
|
|
78
|
+ module:log('debug', 'skip allowners for auth user and non matching room name: %s, jwt room name: %s',
|
|
79
|
+ room_name, session.jitsi_meet_room);
|
75
|
80
|
return;
|
76
|
81
|
end
|
77
|
82
|
|
78
|
83
|
if not (subdomain == session.jitsi_meet_context_group) then
|
79
|
|
- module:log('debug', 'skip allowners for auth user and non matching room subdomain: %s, jwt subdomain: %s', subdomain, session.jitsi_meet_context_group);
|
|
84
|
+ module:log('debug', 'skip allowners for auth user and non matching room subdomain: %s, jwt subdomain: %s',
|
|
85
|
+ subdomain, session.jitsi_meet_context_group);
|
80
|
86
|
return;
|
81
|
87
|
end
|
82
|
88
|
end
|
|
@@ -103,7 +109,10 @@ module:hook_global('config-reloaded', load_config);
|
103
|
109
|
-- We want to filter those presences where we send first `participant` and just after it `moderator`
|
104
|
110
|
function filter_stanza(stanza)
|
105
|
111
|
-- when joining_moderator_participants is empty there is nothing to filter
|
106
|
|
- if next(joining_moderator_participants) == nil or not stanza.attr or not stanza.attr.to or stanza.name ~= "presence" then
|
|
112
|
+ if next(joining_moderator_participants) == nil
|
|
113
|
+ or not stanza.attr
|
|
114
|
+ or not stanza.attr.to
|
|
115
|
+ or stanza.name ~= "presence" then
|
107
|
116
|
return stanza;
|
108
|
117
|
end
|
109
|
118
|
|
|
@@ -146,3 +155,30 @@ end
|
146
|
155
|
|
147
|
156
|
-- enable filtering presences
|
148
|
157
|
filters.add_filter_hook(filter_session);
|
|
158
|
+
|
|
159
|
+-- filters any attempt to revoke owner rights on non moderated rooms
|
|
160
|
+function filter_admin_set_query(event)
|
|
161
|
+ local origin, stanza = event.origin, event.stanza;
|
|
162
|
+ local room_jid = jid_bare(stanza.attr.to);
|
|
163
|
+ local room = get_room_from_jid(room_jid);
|
|
164
|
+
|
|
165
|
+ local item = stanza.tags[1].tags[1];
|
|
166
|
+ local _aff = item.attr.affiliation;
|
|
167
|
+
|
|
168
|
+ -- if it is a moderated room we skip it
|
|
169
|
+ if is_moderated(room.jid) then
|
|
170
|
+ return nil;
|
|
171
|
+ end
|
|
172
|
+
|
|
173
|
+ -- any revoking is disabled
|
|
174
|
+ if _aff ~= 'owner' then
|
|
175
|
+ origin.send(st.error_reply(stanza, "auth", "forbidden"));
|
|
176
|
+ return true;
|
|
177
|
+ end
|
|
178
|
+end
|
|
179
|
+
|
|
180
|
+if not disable_revoke_owners then
|
|
181
|
+ -- default prosody priority for handling these is -2
|
|
182
|
+ module:hook("iq-set/bare/http://jabber.org/protocol/muc#admin:query", filter_admin_set_query, 5);
|
|
183
|
+ module:hook("iq-set/host/http://jabber.org/protocol/muc#admin:query", filter_admin_set_query, 5);
|
|
184
|
+end
|