# HG changeset patch # User Jonas Schäfer # Date 1611606818 -3600 # Node ID 6357ac65b4eb546ddfdafe5e352ebcb31c960d4a # Parent dfb34cc9702835e1cc780578f0b65856fce6c700 mod_groups_internal: allow delay of roster sync on group change This is useful when executing a bulk change (e.g. a creation of a group with many members) to avoid O(n^3). diff -r dfb34cc97028 -r 6357ac65b4eb mod_groups_internal/mod_groups_internal.lua --- a/mod_groups_internal/mod_groups_internal.lua Mon Jan 25 21:32:53 2021 +0100 +++ b/mod_groups_internal/mod_groups_internal.lua Mon Jan 25 21:33:38 2021 +0100 @@ -157,7 +157,7 @@ return nil, "internal-server-error"; end -function add_member(group_id, username) +function add_member(group_id, username, delay_update) local group_info = group_info_store:get(group_id); if not group_info then return nil, "group-not-found"; @@ -165,7 +165,9 @@ if not group_memberships:set(group_id, username, {}) then return nil, "internal-server-error"; end - do_all_group_subscriptions_by_group(group_id); + if not delay_update then + do_all_group_subscriptions_by_group(group_id); + end return true; end @@ -180,6 +182,10 @@ return true; end +function sync(group_id) + do_all_group_subscriptions_by_group(group_id) +end + -- Returns iterator over group ids function groups() return group_info_store:users();