Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix: Avoids sending two metadata updates.

damencho1cea9b178663
diff --git a/resources/prosody-plugins/mod_room_metadata_component.lua b/resources/prosody-plugins/mod_room_metadata_component.lua
index 3b41bedaa0..34c677317d 100644
--- a/resources/prosody-plugins/mod_room_metadata_component.lua
+++ b/resources/prosody-plugins/mod_room_metadata_component.lua
@@ -19,6 +19,7 @@ local internal_room_jid_match_rewrite = util.internal_room_jid_match_rewrite;
local process_host_module = util.process_host_module;
local table_shallow_copy = util.table_shallow_copy;
local table_add = util.table_add;
+local table_equals = util.table_equals;
local MUC_NS = 'http://jabber.org/protocol/muc';
local COMPONENT_IDENTITY_TYPE = 'room_metadata';
@@ -188,12 +189,15 @@ function on_message(event)
jsonData.data = res;
end
- room.jitsiMetadata[jsonData.key] = jsonData.data;
+ local old_value = room.jitsiMetadata[jsonData.key];
+ if not table_equals(old_value, jsonData.data) then
+ room.jitsiMetadata[jsonData.key] = jsonData.data;
- broadcastMetadata(room);
+ broadcastMetadata(room);
- -- fire and event for the change
- main_muc_module:fire_event('jitsi-metadata-updated', { room = room; actor = occupant; key = jsonData.key; });
+ -- fire and event for the change
+ main_muc_module:fire_event('jitsi-metadata-updated', { room = room; actor = occupant; key = jsonData.key; });
+ end
return true;
end
@@ -238,12 +242,24 @@ function process_main_muc_loaded(main_muc, host_module)
local startMutedMetadata = room.jitsiMetadata.startMuted or {};
- startMutedMetadata.audio = startMuted.attr.audio == 'true';
- startMutedMetadata.video = startMuted.attr.video == 'true';
+ local audioNewValue = startMuted.attr.audio == 'true';
+ local videoNewValue = startMuted.attr.video == 'true';
+ local send_update = false;
- room.jitsiMetadata.startMuted = startMutedMetadata;
+ if startMutedMetadata.audio ~= audioNewValue then
+ startMutedMetadata.audio = audioNewValue;
+ send_update = true;
+ end
+ if startMutedMetadata.video ~= videoNewValue then
+ startMutedMetadata.video = videoNewValue;
+ send_update = true;
+ end
- host_module:fire_event('room-metadata-changed', { room = room; });
+ if send_update then
+ room.jitsiMetadata.startMuted = startMutedMetadata;
+
+ host_module:fire_event('room-metadata-changed', { room = room; });
+ end
end);
end
diff --git a/resources/prosody-plugins/util.lib.lua b/resources/prosody-plugins/util.lib.lua
index 35deb9b067..f16e267097 100644
--- a/resources/prosody-plugins/util.lib.lua
+++ b/resources/prosody-plugins/util.lib.lua
@@ -638,6 +638,19 @@ local function table_compare(old_table, new_table)
return removed, added
end
+local function table_equals(t1, t2)
+ if t1 == nil then
+ return t2 == nil;
+ end
+ if t2 == nil then
+ return t1 == nil;
+ end
+
+ local removed, added = table_compare(t1, t2);
+
+ return next(removed) == nil and next(added) == nil
+end
+
-- Splits a string using delimiter
function split_string(str, delimiter)
str = str .. delimiter;
@@ -746,4 +759,5 @@ return {
table_compare = table_compare;
table_shallow_copy = table_shallow_copy;
table_find = table_find;
+ table_equals = table_equals;
};