Changeset

4386:6357ac65b4eb

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).
author Jonas Schäfer <jonas@wielicki.name>
date Mon, 25 Jan 2021 21:33:38 +0100
parents 4385:dfb34cc97028
children 4387:e5b4ebacbf7a
files mod_groups_internal/mod_groups_internal.lua
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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();