|
@@ -14,7 +14,8 @@ local jid = require 'util.jid';
|
14
|
14
|
local st = require 'util.stanza';
|
15
|
15
|
local new_id = require 'util.id'.medium;
|
16
|
16
|
local filters = require 'util.filters';
|
17
|
|
-local array = require"util.array";
|
|
17
|
+local array = require 'util.array';
|
|
18
|
+local set = require 'util.set';
|
18
|
19
|
|
19
|
20
|
local util = module:require 'util';
|
20
|
21
|
local ends_with = util.ends_with;
|
|
@@ -69,13 +70,11 @@ end
|
69
|
70
|
|
70
|
71
|
local function send_transcriptions_update(room)
|
71
|
72
|
-- let's notify main prosody
|
72
|
|
- local lang_array = array{};
|
|
73
|
+ local lang_array = array();
|
73
|
74
|
local count = 0;
|
74
|
75
|
|
75
|
76
|
for k, v in pairs(room._transcription_languages) do
|
76
|
|
- if not lang_array[v] then
|
77
|
|
- lang_array:push(v);
|
78
|
|
- end
|
|
77
|
+ lang_array:push(v);
|
79
|
78
|
count = count + 1;
|
80
|
79
|
end
|
81
|
80
|
|
|
@@ -90,7 +89,7 @@ local function send_transcriptions_update(room)
|
90
|
89
|
room = jid.join(jid.node(room.jid), muc_domain_prefix..'.'..main_domain) })
|
91
|
90
|
:tag('transcription-languages', {
|
92
|
91
|
xmlns = 'jitsi:visitors',
|
93
|
|
- langs = lang_array:sort():concat(','),
|
|
92
|
+ langs = lang_array:unique():sort():concat(','),
|
94
|
93
|
count = tostring(count)
|
95
|
94
|
}):up());
|
96
|
95
|
end
|
|
@@ -127,8 +126,14 @@ end
|
127
|
126
|
module:hook('muc-occupant-pre-join', function (event)
|
128
|
127
|
local occupant, room, origin, stanza = event.occupant, event.room, event.origin, event.stanza;
|
129
|
128
|
local node, host = jid.split(occupant.bare_jid);
|
|
129
|
+ local resource = jid.resource(occupant.nick);
|
|
130
|
+
|
|
131
|
+ if is_admin(occupant.bare_jid) then
|
|
132
|
+ return;
|
|
133
|
+ end
|
130
|
134
|
|
131
|
|
- if prosody.hosts[host] and not is_admin(occupant.bare_jid) then
|
|
135
|
+ if prosody.hosts[host] then
|
|
136
|
+ -- local participants which host is defined in this prosody
|
132
|
137
|
if room._main_room_lobby_enabled then
|
133
|
138
|
origin.send(st.error_reply(stanza, 'cancel', 'not-allowed', 'Visitors not allowed while lobby is on!')
|
134
|
139
|
:tag('no-visitors-lobby', { xmlns = 'jitsi:visitors' }));
|
|
@@ -136,6 +141,9 @@ module:hook('muc-occupant-pre-join', function (event)
|
136
|
141
|
else
|
137
|
142
|
occupant.role = 'visitor';
|
138
|
143
|
end
|
|
144
|
+ elseif room.moderators_list:contains(resource) then
|
|
145
|
+ -- remote participants, host is the main prosody
|
|
146
|
+ occupant.role = 'moderator';
|
139
|
147
|
end
|
140
|
148
|
end, 3);
|
141
|
149
|
|
|
@@ -399,7 +407,7 @@ local function stanza_handler(event)
|
399
|
407
|
local room = get_room_from_jid(room_jid_match_rewrite(room_jid));
|
400
|
408
|
|
401
|
409
|
if not room then
|
402
|
|
- module:log('warn', 'No room found %s', room_jid);
|
|
410
|
+ module:log('warn', 'No room found %s in stanza_handler', room_jid);
|
403
|
411
|
return;
|
404
|
412
|
end
|
405
|
413
|
|
|
@@ -546,7 +554,15 @@ module:hook('jicofo-unlock-room', function(e)
|
546
|
554
|
return true;
|
547
|
555
|
end);
|
548
|
556
|
|
|
557
|
+-- handles incoming iq visitors stanzas
|
|
558
|
+-- connect - sent after sending all main participant's presences
|
|
559
|
+-- disconnect - sent when main room is destroyed or when we receive a 'disconnect-vnode' iq from jicofo
|
|
560
|
+-- update - sent on:
|
|
561
|
+-- * room secret is changed
|
|
562
|
+-- * lobby enabled or disabled
|
|
563
|
+-- * initially before connect to report currently joined moderators
|
|
564
|
+-- * moderator participant joins main room
|
|
565
|
+-- * a participant has been granted moderator rights
|
549
|
566
|
local function iq_from_main_handler(event)
|
550
|
567
|
local origin, stanza = event.origin, event.stanza;
|
551
|
568
|
|
|
@@ -577,7 +593,7 @@ local function iq_from_main_handler(event)
|
577
|
593
|
local room = get_room_from_jid(room_jid_match_rewrite(room_jid));
|
578
|
594
|
|
579
|
595
|
if not room then
|
580
|
|
- module:log('warn', 'No room found %s', room_jid);
|
|
596
|
+ module:log('warn', 'No room found %s in iq_from_main_handler for:%s', room_jid, visitors_iq);
|
581
|
597
|
return;
|
582
|
598
|
end
|
583
|
599
|
|
|
@@ -625,6 +641,28 @@ local function iq_from_main_handler(event)
|
625
|
641
|
room._main_room_lobby_enabled = false;
|
626
|
642
|
end
|
627
|
643
|
|
|
644
|
+ -- read the moderators list
|
|
645
|
+ room.moderators_list = room.moderators_list or set.new();
|
|
646
|
+ local moderators = node:get_child('moderators');
|
|
647
|
+
|
|
648
|
+ if moderators then
|
|
649
|
+ for _, child in ipairs(moderators.tags) do
|
|
650
|
+ if child.name == 'item' then
|
|
651
|
+ room.moderators_list:add(child.attr.epId);
|
|
652
|
+ end
|
|
653
|
+ end
|
|
654
|
+
|
|
655
|
+ -- let's check current occupants roles and promote them if needed
|
|
656
|
+ -- we change only main participants which are not moderators, but participant
|
|
657
|
+ for _, o in room:each_occupant() do
|
|
658
|
+ if not is_admin(o.bare_jid)
|
|
659
|
+ and o.role == 'participant'
|
|
660
|
+ and room.moderators_list:contains(jid.resource(o.nick)) then
|
|
661
|
+ room:set_affiliation(true, o.bare_jid, 'owner');
|
|
662
|
+ end
|
|
663
|
+ end
|
|
664
|
+ end
|
|
665
|
+
|
628
|
666
|
if fire_jicofo_unlock then
|
629
|
667
|
-- everything is connected allow participants to join
|
630
|
668
|
module:fire_event('jicofo-unlock-room', { room = room; fmuc_fired = true; });
|