A platform for community discussion. Free, open, simple.
DEV: Put back the `model` step in HandleCategoryUpdated service
Loïc Guitautf11f2b983f18
diff --git a/plugins/chat/app/services/chat/auto_remove/handle_category_updated.rb b/plugins/chat/app/services/chat/auto_remove/handle_category_updated.rbindex 030f2da38d9..fff835bc986 100644--- a/plugins/chat/app/services/chat/auto_remove/handle_category_updated.rb+++ b/plugins/chat/app/services/chat/auto_remove/handle_category_updated.rb@@ -19,6 +19,7 @@ module Chatpolicy :chat_enabledmodel :categorymodel :category_channel_ids+ model :usersstep :remove_users_without_channel_permissionstep :publish@@ -46,18 +47,21 @@ module ChatChat::Channel.where(chatable: category).pluck(:id)end- def remove_users_without_channel_permission(category_channel_ids:)+ def fetch_users(category_channel_ids:)+ User+ .real+ .activated+ .not_suspended+ .not_staged+ .joins(:user_chat_channel_memberships)+ .where("user_chat_channel_memberships.chat_channel_id IN (?)", category_channel_ids)+ .where("NOT admin AND NOT moderator")+ end++ def remove_users_without_channel_permission(users:, category_channel_ids:)memberships_to_remove =Chat::Action::CalculateMembershipsForRemoval.call(- scoped_users_query:- User- .real- .activated- .not_suspended- .not_staged- .joins(:user_chat_channel_memberships)- .where("user_chat_channel_memberships.chat_channel_id IN (?)", category_channel_ids)- .where("NOT admin AND NOT moderator"),+ scoped_users_query: users,channel_ids: category_channel_ids,)