|
|
@@ -214,6 +214,16 @@ function get_visitors_languages(room)
|
|
214
|
214
|
return count, languages:sort():concat(',');
|
|
215
|
215
|
end
|
|
216
|
216
|
|
|
|
217
|
+local function get_visitors_room_metadata(room)
|
|
|
218
|
+ if not room.jitsiMetadata then
|
|
|
219
|
+ room.jitsiMetadata = {};
|
|
|
220
|
+ end
|
|
|
221
|
+ if not room.jitsiMetadata.visitors then
|
|
|
222
|
+ room.jitsiMetadata.visitors = {};
|
|
|
223
|
+ end
|
|
|
224
|
+ return room.jitsiMetadata.visitors;
|
|
|
225
|
+end
|
|
|
226
|
+
|
|
217
|
227
|
-- listens for iq request for promotion and forward it to moderators in the meeting for approval
|
|
218
|
228
|
-- or auto-allow it if such the config is set enabling it
|
|
219
|
229
|
local function stanza_handler(event)
|
|
|
@@ -300,12 +310,8 @@ local function stanza_handler(event)
|
|
300
|
310
|
module:log('warn', 'Received forged transcription_languages message: %s %s',stanza, inspect(room._connected_vnodes));
|
|
301
|
311
|
return true; -- stop processing
|
|
302
|
312
|
end
|
|
303
|
|
- if not room.jitsiMetadata then
|
|
304
|
|
- room.jitsiMetadata = {};
|
|
305
|
|
- end
|
|
306
|
|
- if not room.jitsiMetadata.visitors then
|
|
307
|
|
- room.jitsiMetadata.visitors = {};
|
|
308
|
|
- end
|
|
|
313
|
+
|
|
|
314
|
+ local metadata = get_visitors_room_metadata(room);
|
|
309
|
315
|
|
|
310
|
316
|
-- we keep the split by languages array to optimize accumulating languages
|
|
311
|
317
|
from_vnode.langs = split_string(transcription_languages.attr.langs, ',');
|
|
|
@@ -313,13 +319,13 @@ local function stanza_handler(event)
|
|
313
|
319
|
|
|
314
|
320
|
local count, languages = get_visitors_languages(room);
|
|
315
|
321
|
|
|
316
|
|
- if room.jitsiMetadata.visitors.transcribingLanguages ~= languages then
|
|
317
|
|
- room.jitsiMetadata.visitors.transcribingLanguages = languages;
|
|
|
322
|
+ if metadata.transcribingLanguages ~= languages then
|
|
|
323
|
+ metadata.transcribingLanguages = languages;
|
|
318
|
324
|
processed = true;
|
|
319
|
325
|
end
|
|
320
|
326
|
|
|
321
|
|
- if room.jitsiMetadata.visitors.transcribingCount ~= count then
|
|
322
|
|
- room.jitsiMetadata.visitors.transcribingCount = count;
|
|
|
327
|
+ if metadata.transcribingCount ~= count then
|
|
|
328
|
+ metadata.transcribingCount = count;
|
|
323
|
329
|
processed = true;
|
|
324
|
330
|
end
|
|
325
|
331
|
|
|
|
@@ -338,6 +344,11 @@ local function stanza_handler(event)
|
|
338
|
344
|
end
|
|
339
|
345
|
|
|
340
|
346
|
local function process_promotion_response(room, id, approved)
|
|
|
347
|
+ if not approved then
|
|
|
348
|
+ module:log('debug', 'promotion not approved %s, %s', room.jid, id);
|
|
|
349
|
+ return;
|
|
|
350
|
+ end
|
|
|
351
|
+
|
|
341
|
352
|
-- lets reply to participant that requested promotion
|
|
342
|
353
|
local username = new_id():lower();
|
|
343
|
354
|
visitors_promotion_map[room.jid][username] = {
|
|
|
@@ -452,10 +463,23 @@ process_host_module(muc_domain_prefix..'.'..muc_domain_base, function(host_modul
|
|
452
|
463
|
end
|
|
453
|
464
|
|
|
454
|
465
|
if visitors_promotion_map[room.jid] then
|
|
|
466
|
+ local in_ignore_list = ignore_list:contains(jid.host(stanza.attr.from));
|
|
|
467
|
+
|
|
455
|
468
|
-- now let's check for jid
|
|
456
|
469
|
if visitors_promotion_map[room.jid][jid.node(stanza.attr.from)] -- promotion was approved
|
|
457
|
|
- or ignore_list:contains(jid.host(stanza.attr.from)) then -- jibri or other domains to ignore
|
|
|
470
|
+ or in_ignore_list then -- jibri or other domains to ignore
|
|
458
|
471
|
-- allow join
|
|
|
472
|
+ if not in_ignore_list then
|
|
|
473
|
+ -- let's update metadata
|
|
|
474
|
+ local metadata = get_visitors_room_metadata(room);
|
|
|
475
|
+ if not metadata.promoted then
|
|
|
476
|
+ metadata.promoted = {};
|
|
|
477
|
+ end
|
|
|
478
|
+ metadata.promoted[jid.resource(occupant.nick)] = true;
|
|
|
479
|
+ module:context(muc_domain_prefix..'.'..muc_domain_base)
|
|
|
480
|
+ :fire_event('room-metadata-changed', { room = room; });
|
|
|
481
|
+ end
|
|
|
482
|
+
|
|
459
|
483
|
return;
|
|
460
|
484
|
end
|
|
461
|
485
|
module:log('error', 'Visitor needs to be allowed by a moderator %s', stanza.attr.from);
|