Skip to content

A platform for community discussion. Free, open, simple.

SECURITY: mutex around adding users to a group DM

zogstripbae4cd165f03
diff --git a/plugins/chat/app/services/chat/add_users_to_channel.rb b/plugins/chat/app/services/chat/add_users_to_channel.rb
index 60309f65758..7ac9e6d165e 100644
--- a/plugins/chat/app/services/chat/add_users_to_channel.rb
+++ b/plugins/chat/app/services/chat/add_users_to_channel.rb
@@ -38,16 +38,18 @@ module Chat
end
end
- model :channel
- policy :can_add_users_to_channel
- model :target_users, optional: true
- policy :satisfies_dms_max_users_limit,
- class_name: Chat::DirectMessageChannel::Policy::MaxUsersExcess
-
- transaction do
- step :upsert_memberships
- step :recompute_users_count
- step :notice_channel
+ lock(:channel_id) do
+ model :channel
+ policy :can_add_users_to_channel
+ model :target_users, optional: true
+ policy :satisfies_dms_max_users_limit,
+ class_name: Chat::DirectMessageChannel::Policy::MaxUsersExcess
+
+ transaction do
+ step :upsert_memberships
+ step :recompute_users_count
+ step :notice_channel
+ end
end
private