From ad8f46f4f1e6294319c9194a1beede66d308e64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Wed, 2 Oct 2024 16:07:57 +0200 Subject: [PATCH] DEV: Make params explicit for services in controllers --- app/controllers/admin/admin_notices_controller.rb | 2 +- app/controllers/admin/config/flags_controller.rb | 10 +++++----- app/controllers/admin/site_settings_controller.rb | 2 +- app/controllers/admin/users_controller.rb | 4 ++-- app/controllers/application_controller.rb | 4 ++++ lib/service/runner.rb | 6 +----- .../chat/api/channel_messages_controller.rb | 12 ++++++------ .../chat/api/channel_thread_messages_controller.rb | 2 +- .../chat/api/channel_threads_controller.rb | 8 ++++---- ...current_user_notifications_settings_controller.rb | 2 +- ...eads_current_user_title_prompt_seen_controller.rb | 2 +- .../app/controllers/chat/api/channels_controller.rb | 6 +++--- .../channels_current_user_membership_controller.rb | 2 +- ...els_current_user_membership_follows_controller.rb | 2 +- .../chat/api/channels_drafts_controller.rb | 2 +- .../chat/api/channels_invites_controller.rb | 2 +- .../chat/api/channels_memberships_controller.rb | 2 +- .../chat/api/channels_messages_flags_controller.rb | 2 +- .../api/channels_messages_streaming_controller.rb | 2 +- .../controllers/chat/api/channels_read_controller.rb | 4 ++-- .../chat/api/channels_status_controller.rb | 2 +- .../chat/api/channels_threads_drafts_controller.rb | 2 +- .../chat/api/channels_threads_read_controller.rb | 2 +- .../app/controllers/chat/api/chatables_controller.rb | 2 +- .../chat/api/current_user_channels_controller.rb | 2 +- .../chat/api/current_user_threads_controller.rb | 2 +- .../chat/api/direct_messages_controller.rb | 2 +- .../controllers/chat/incoming_webhooks_controller.rb | 10 ++++++---- 28 files changed, 52 insertions(+), 50 deletions(-) diff --git a/app/controllers/admin/admin_notices_controller.rb b/app/controllers/admin/admin_notices_controller.rb index d19f763f1bd..44c787abb87 100644 --- a/app/controllers/admin/admin_notices_controller.rb +++ b/app/controllers/admin/admin_notices_controller.rb @@ -2,7 +2,7 @@ class Admin::AdminNoticesController < Admin::StaffController def destroy - AdminNotices::Dismiss.call do + AdminNotices::Dismiss.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } end diff --git a/app/controllers/admin/config/flags_controller.rb b/app/controllers/admin/config/flags_controller.rb index 7799e186c26..6e46a7e0857 100644 --- a/app/controllers/admin/config/flags_controller.rb +++ b/app/controllers/admin/config/flags_controller.rb @@ -2,7 +2,7 @@ class Admin::Config::FlagsController < Admin::AdminController def toggle - Flags::ToggleFlag.call do + Flags::ToggleFlag.call(service_params) do on_success do Discourse.request_refresh! render(json: success_json) @@ -26,7 +26,7 @@ class Admin::Config::FlagsController < Admin::AdminController end def create - Flags::CreateFlag.call do + Flags::CreateFlag.call(service_params) do on_success do Discourse.request_refresh! render json: result.flag, serializer: FlagSerializer, used_flag_ids: Flag.used_flag_ids @@ -41,7 +41,7 @@ class Admin::Config::FlagsController < Admin::AdminController end def update - Flags::UpdateFlag.call do + Flags::UpdateFlag.call(service_params) do on_success do Discourse.request_refresh! render json: result.flag, serializer: FlagSerializer, used_flag_ids: Flag.used_flag_ids @@ -59,7 +59,7 @@ class Admin::Config::FlagsController < Admin::AdminController end def reorder - Flags::ReorderFlag.call do + Flags::ReorderFlag.call(service_params) do on_success do Discourse.request_refresh! render(json: success_json) @@ -75,7 +75,7 @@ class Admin::Config::FlagsController < Admin::AdminController end def destroy - Flags::DestroyFlag.call do + Flags::DestroyFlag.call(service_params) do on_success do Discourse.request_refresh! render(json: success_json) diff --git a/app/controllers/admin/site_settings_controller.rb b/app/controllers/admin/site_settings_controller.rb index 45c2b9c7ec9..e832e945273 100644 --- a/app/controllers/admin/site_settings_controller.rb +++ b/app/controllers/admin/site_settings_controller.rb @@ -39,7 +39,7 @@ class Admin::SiteSettingsController < Admin::AdminController previous_value = value_or_default(SiteSetting.get(id)) if update_existing_users - UpdateSiteSetting.call(setting_name: id, new_value: value) do + UpdateSiteSetting.call(service_params.merge(setting_name: id, new_value: value)) do on_success do if update_existing_users SiteSettingUpdateExistingUsers.call(id, result.new_value, previous_value) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 94594b8f085..e40c9116502 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -120,7 +120,7 @@ class Admin::UsersController < Admin::StaffController end def suspend - User::Suspend.call do + User::Suspend.call(service_params) do on_success do render_json_dump( suspension: { @@ -315,7 +315,7 @@ class Admin::UsersController < Admin::StaffController end def silence - User::Silence.call do + User::Silence.call(service_params) do on_success do render_json_dump( silence: { diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e50a212bcac..90ca5f2da5b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1162,4 +1162,8 @@ class ApplicationController < ActionController::Base def clean_xml response.body.gsub!(XmlCleaner::INVALID_CHARACTERS, "") end + + def service_params + params.to_unsafe_h.merge(guardian:) + end end diff --git a/lib/service/runner.rb b/lib/service/runner.rb index 148ab0119db..794a3cc4c36 100644 --- a/lib/service/runner.rb +++ b/lib/service/runner.rb @@ -134,13 +134,9 @@ class Service::Runner def setup_and_run_service runner = self - params = object.try(:params) || ActionController::Parameters.new object.instance_eval do def result = @_result - @_result = - runner.service.call( - params.to_unsafe_h.merge(guardian: try(:guardian), **runner.dependencies), - ) + @_result = runner.service.call(runner.dependencies) end end diff --git a/plugins/chat/app/controllers/chat/api/channel_messages_controller.rb b/plugins/chat/app/controllers/chat/api/channel_messages_controller.rb index a715ed9b111..e706614ec55 100644 --- a/plugins/chat/app/controllers/chat/api/channel_messages_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channel_messages_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelMessagesController < Chat::ApiController def index - ::Chat::ListChannelMessages.call do + ::Chat::ListChannelMessages.call(service_params) do on_success { render_serialized(result, ::Chat::MessagesSerializer, root: false) } on_failure { render(json: failed_json, status: 422) } on_failed_policy(:can_view_channel) { raise Discourse::InvalidAccess } @@ -15,7 +15,7 @@ class Chat::Api::ChannelMessagesController < Chat::ApiController end def destroy - Chat::TrashMessage.call do + Chat::TrashMessage.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_model_not_found(:message) { raise Discourse::NotFound } @@ -27,7 +27,7 @@ class Chat::Api::ChannelMessagesController < Chat::ApiController end def bulk_destroy - Chat::TrashMessages.call do + Chat::TrashMessages.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_model_not_found(:messages) { raise Discourse::NotFound } @@ -39,7 +39,7 @@ class Chat::Api::ChannelMessagesController < Chat::ApiController end def restore - Chat::RestoreMessage.call do + Chat::RestoreMessage.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess } @@ -51,7 +51,7 @@ class Chat::Api::ChannelMessagesController < Chat::ApiController end def update - Chat::UpdateMessage.call do + Chat::UpdateMessage.call(service_params) do on_success { render json: success_json.merge(message_id: result[:message].id) } on_failure { render(json: failed_json, status: 422) } on_model_not_found(:message) { raise Discourse::NotFound } @@ -68,7 +68,7 @@ class Chat::Api::ChannelMessagesController < Chat::ApiController Chat::MessageRateLimiter.run!(current_user) # users can't force a thread through JSON API - Chat::CreateMessage.call(force_thread: false) do + Chat::CreateMessage.call(service_params.merge(force_thread: false)) do on_success { render json: success_json.merge(message_id: result[:message_instance].id) } on_failure { render(json: failed_json, status: 422) } on_failed_policy(:no_silenced_user) { raise Discourse::InvalidAccess } diff --git a/plugins/chat/app/controllers/chat/api/channel_thread_messages_controller.rb b/plugins/chat/app/controllers/chat/api/channel_thread_messages_controller.rb index b487b77bb8e..27fc14ce4b2 100644 --- a/plugins/chat/app/controllers/chat/api/channel_thread_messages_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channel_thread_messages_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelThreadMessagesController < Chat::ApiController def index - ::Chat::ListChannelThreadMessages.call do + ::Chat::ListChannelThreadMessages.call(service_params) do on_success do render_serialized( result, diff --git a/plugins/chat/app/controllers/chat/api/channel_threads_controller.rb b/plugins/chat/app/controllers/chat/api/channel_threads_controller.rb index 98588d34479..52d4daf97f7 100644 --- a/plugins/chat/app/controllers/chat/api/channel_threads_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channel_threads_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelThreadsController < Chat::ApiController def index - ::Chat::LookupChannelThreads.call do + ::Chat::LookupChannelThreads.call(service_params) do on_success do render_serialized( ::Chat::ThreadsView.new( @@ -30,7 +30,7 @@ class Chat::Api::ChannelThreadsController < Chat::ApiController end def show - ::Chat::LookupThread.call do + ::Chat::LookupThread.call(service_params) do on_success do render_serialized( result.thread, @@ -53,7 +53,7 @@ class Chat::Api::ChannelThreadsController < Chat::ApiController end def update - ::Chat::UpdateThread.call do + ::Chat::UpdateThread.call(service_params) do on_failed_policy(:threading_enabled_for_channel) { raise Discourse::NotFound } on_failed_policy(:can_view_channel) { raise Discourse::InvalidAccess } on_failed_policy(:can_edit_thread) { raise Discourse::InvalidAccess } @@ -70,7 +70,7 @@ class Chat::Api::ChannelThreadsController < Chat::ApiController end def create - ::Chat::CreateThread.call do + ::Chat::CreateThread.call(service_params) do on_success do render_serialized( result.thread, diff --git a/plugins/chat/app/controllers/chat/api/channel_threads_current_user_notifications_settings_controller.rb b/plugins/chat/app/controllers/chat/api/channel_threads_current_user_notifications_settings_controller.rb index 73008eddcb0..7880827d19b 100644 --- a/plugins/chat/app/controllers/chat/api/channel_threads_current_user_notifications_settings_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channel_threads_current_user_notifications_settings_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelThreadsCurrentUserNotificationsSettingsController < Chat::ApiController def update - Chat::UpdateThreadNotificationSettings.call do + Chat::UpdateThreadNotificationSettings.call(service_params) do on_failed_policy(:threading_enabled_for_channel) { raise Discourse::NotFound } on_failed_policy(:can_view_channel) { raise Discourse::InvalidAccess } on_model_not_found(:thread) { raise Discourse::NotFound } diff --git a/plugins/chat/app/controllers/chat/api/channel_threads_current_user_title_prompt_seen_controller.rb b/plugins/chat/app/controllers/chat/api/channel_threads_current_user_title_prompt_seen_controller.rb index 7f276856745..b37fd1a4bc3 100644 --- a/plugins/chat/app/controllers/chat/api/channel_threads_current_user_title_prompt_seen_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channel_threads_current_user_title_prompt_seen_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelThreadsCurrentUserTitlePromptSeenController < Chat::ApiController def update - Chat::MarkThreadTitlePromptSeen.call do + Chat::MarkThreadTitlePromptSeen.call(service_params) do on_failed_policy(:threading_enabled_for_channel) { raise Discourse::NotFound } on_failed_policy(:can_view_channel) { raise Discourse::InvalidAccess } on_model_not_found(:thread) { raise Discourse::NotFound } diff --git a/plugins/chat/app/controllers/chat/api/channels_controller.rb b/plugins/chat/app/controllers/chat/api/channels_controller.rb index 5ea7a649699..6e6ca0ef379 100644 --- a/plugins/chat/app/controllers/chat/api/channels_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_controller.rb @@ -33,7 +33,7 @@ class Chat::Api::ChannelsController < Chat::ApiController end def destroy - Chat::TrashChannel.call do + Chat::TrashChannel.call(service_params) do on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess } on_model_not_found(:channel) { raise ActiveRecord::RecordNotFound } on_success { render(json: success_json) } @@ -59,7 +59,7 @@ class Chat::Api::ChannelsController < Chat::ApiController # at the moment. This may change in future, at which point we will need to pass in # a chatable_type param as well and switch to the correct service here. Chat::CreateCategoryChannel.call( - channel_params.merge(category_id: channel_params[:chatable_id]), + service_params.merge(channel_params.merge(category_id: channel_params[:chatable_id])), ) do on_success do render_serialized( @@ -104,7 +104,7 @@ class Chat::Api::ChannelsController < Chat::ApiController auto_join_limiter(channel_from_params).performed! end - Chat::UpdateChannel.call(params_to_edit) do + Chat::UpdateChannel.call(service_params.merge(params_to_edit)) do on_success do render_serialized( result.channel, diff --git a/plugins/chat/app/controllers/chat/api/channels_current_user_membership_controller.rb b/plugins/chat/app/controllers/chat/api/channels_current_user_membership_controller.rb index 00f5e6e51e0..b7bf7e51249 100644 --- a/plugins/chat/app/controllers/chat/api/channels_current_user_membership_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_current_user_membership_controller.rb @@ -12,7 +12,7 @@ class Chat::Api::ChannelsCurrentUserMembershipController < Chat::Api::ChannelsCo end def destroy - Chat::LeaveChannel.call do + Chat::LeaveChannel.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_model_not_found(:channel) { raise Discourse::NotFound } diff --git a/plugins/chat/app/controllers/chat/api/channels_current_user_membership_follows_controller.rb b/plugins/chat/app/controllers/chat/api/channels_current_user_membership_follows_controller.rb index 47f0dcaeb06..b1da98b2773 100644 --- a/plugins/chat/app/controllers/chat/api/channels_current_user_membership_follows_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_current_user_membership_follows_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelsCurrentUserMembershipFollowsController < Chat::Api::ChannelsController def destroy - Chat::UnfollowChannel.call do + Chat::UnfollowChannel.call(service_params) do on_success do render_serialized( result.membership, diff --git a/plugins/chat/app/controllers/chat/api/channels_drafts_controller.rb b/plugins/chat/app/controllers/chat/api/channels_drafts_controller.rb index 997a4f3336e..b221aa74744 100644 --- a/plugins/chat/app/controllers/chat/api/channels_drafts_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_drafts_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelsDraftsController < Chat::ApiController def create - Chat::UpsertDraft.call do + Chat::UpsertDraft.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_model_not_found(:channel) { raise Discourse::NotFound } diff --git a/plugins/chat/app/controllers/chat/api/channels_invites_controller.rb b/plugins/chat/app/controllers/chat/api/channels_invites_controller.rb index f5b1469df5b..ca992049184 100644 --- a/plugins/chat/app/controllers/chat/api/channels_invites_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_invites_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelsInvitesController < Chat::ApiController def create - Chat::InviteUsersToChannel.call do + Chat::InviteUsersToChannel.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_failed_policy(:can_view_channel) { raise Discourse::InvalidAccess } diff --git a/plugins/chat/app/controllers/chat/api/channels_memberships_controller.rb b/plugins/chat/app/controllers/chat/api/channels_memberships_controller.rb index 116ec7a7629..3224a7abb7f 100644 --- a/plugins/chat/app/controllers/chat/api/channels_memberships_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_memberships_controller.rb @@ -30,7 +30,7 @@ class Chat::Api::ChannelsMembershipsController < Chat::Api::ChannelsController end def create - Chat::AddUsersToChannel.call do + Chat::AddUsersToChannel.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_failed_policy(:can_add_users_to_channel) do diff --git a/plugins/chat/app/controllers/chat/api/channels_messages_flags_controller.rb b/plugins/chat/app/controllers/chat/api/channels_messages_flags_controller.rb index 09429d52046..a3fd12eba5e 100644 --- a/plugins/chat/app/controllers/chat/api/channels_messages_flags_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_messages_flags_controller.rb @@ -4,7 +4,7 @@ class Chat::Api::ChannelsMessagesFlagsController < Chat::ApiController def create RateLimiter.new(current_user, "flag_chat_message", 4, 1.minutes).performed! - Chat::FlagMessage.call do + Chat::FlagMessage.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_model_not_found(:message) { raise Discourse::NotFound } diff --git a/plugins/chat/app/controllers/chat/api/channels_messages_streaming_controller.rb b/plugins/chat/app/controllers/chat/api/channels_messages_streaming_controller.rb index 930ffd1d777..5094f9dd39d 100644 --- a/plugins/chat/app/controllers/chat/api/channels_messages_streaming_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_messages_streaming_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelsMessagesStreamingController < Chat::Api::ChannelsController def destroy - Chat::StopMessageStreaming.call do + Chat::StopMessageStreaming.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_model_not_found(:message) { raise Discourse::NotFound } diff --git a/plugins/chat/app/controllers/chat/api/channels_read_controller.rb b/plugins/chat/app/controllers/chat/api/channels_read_controller.rb index 115e4b61cfb..2549d15a3e8 100644 --- a/plugins/chat/app/controllers/chat/api/channels_read_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_read_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelsReadController < Chat::ApiController def update - Chat::UpdateUserChannelLastRead.call do + Chat::UpdateUserChannelLastRead.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_failed_policy(:ensure_message_id_recency) do @@ -19,7 +19,7 @@ class Chat::Api::ChannelsReadController < Chat::ApiController end def update_all - Chat::MarkAllUserChannelsRead.call do + Chat::MarkAllUserChannelsRead.call(service_params) do on_success do render(json: success_json.merge(updated_memberships: result.updated_memberships)) end diff --git a/plugins/chat/app/controllers/chat/api/channels_status_controller.rb b/plugins/chat/app/controllers/chat/api/channels_status_controller.rb index de25b2d6027..6f83c3223e8 100644 --- a/plugins/chat/app/controllers/chat/api/channels_status_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_status_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelsStatusController < Chat::Api::ChannelsController def update - Chat::UpdateChannelStatus.call do + Chat::UpdateChannelStatus.call(service_params) do on_success { render_serialized(result.channel, Chat::ChannelSerializer, root: "channel") } on_model_not_found(:channel) { raise ActiveRecord::RecordNotFound } on_failed_policy(:check_channel_permission) { raise Discourse::InvalidAccess } diff --git a/plugins/chat/app/controllers/chat/api/channels_threads_drafts_controller.rb b/plugins/chat/app/controllers/chat/api/channels_threads_drafts_controller.rb index 24ebb9bd93d..292fbbbfd22 100644 --- a/plugins/chat/app/controllers/chat/api/channels_threads_drafts_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_threads_drafts_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelsThreadsDraftsController < Chat::ApiController def create - Chat::UpsertDraft.call do + Chat::UpsertDraft.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_model_not_found(:channel) { raise Discourse::NotFound } diff --git a/plugins/chat/app/controllers/chat/api/channels_threads_read_controller.rb b/plugins/chat/app/controllers/chat/api/channels_threads_read_controller.rb index cf4bcf7631c..cc147436003 100644 --- a/plugins/chat/app/controllers/chat/api/channels_threads_read_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_threads_read_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::ChannelsThreadsReadController < Chat::ApiController def update - Chat::UpdateUserThreadLastRead.call do + Chat::UpdateUserThreadLastRead.call(service_params) do on_success { render(json: success_json) } on_failure { render(json: failed_json, status: 422) } on_model_not_found(:thread) { raise Discourse::NotFound } diff --git a/plugins/chat/app/controllers/chat/api/chatables_controller.rb b/plugins/chat/app/controllers/chat/api/chatables_controller.rb index b22fd62a043..e59a0bb729d 100644 --- a/plugins/chat/app/controllers/chat/api/chatables_controller.rb +++ b/plugins/chat/app/controllers/chat/api/chatables_controller.rb @@ -4,7 +4,7 @@ class Chat::Api::ChatablesController < Chat::ApiController before_action :ensure_logged_in def index - ::Chat::SearchChatable.call do + ::Chat::SearchChatable.call(service_params) do on_success { render_serialized(result, ::Chat::ChatablesSerializer, root: false) } on_failure { render(json: failed_json, status: 422) } on_failed_contract do |contract| diff --git a/plugins/chat/app/controllers/chat/api/current_user_channels_controller.rb b/plugins/chat/app/controllers/chat/api/current_user_channels_controller.rb index a508ac9276c..2e14301cf74 100644 --- a/plugins/chat/app/controllers/chat/api/current_user_channels_controller.rb +++ b/plugins/chat/app/controllers/chat/api/current_user_channels_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::CurrentUserChannelsController < Chat::ApiController def index - Chat::ListUserChannels.call do + Chat::ListUserChannels.call(service_params) do on_success do render_serialized( result.structured, diff --git a/plugins/chat/app/controllers/chat/api/current_user_threads_controller.rb b/plugins/chat/app/controllers/chat/api/current_user_threads_controller.rb index 02de0a3fd3d..d781b526718 100644 --- a/plugins/chat/app/controllers/chat/api/current_user_threads_controller.rb +++ b/plugins/chat/app/controllers/chat/api/current_user_threads_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::CurrentUserThreadsController < Chat::ApiController def index - ::Chat::LookupUserThreads.call do + ::Chat::LookupUserThreads.call(service_params) do on_success do render_serialized( ::Chat::ThreadsView.new( diff --git a/plugins/chat/app/controllers/chat/api/direct_messages_controller.rb b/plugins/chat/app/controllers/chat/api/direct_messages_controller.rb index 62b427977f9..63c98f973d6 100644 --- a/plugins/chat/app/controllers/chat/api/direct_messages_controller.rb +++ b/plugins/chat/app/controllers/chat/api/direct_messages_controller.rb @@ -2,7 +2,7 @@ class Chat::Api::DirectMessagesController < Chat::ApiController def create - Chat::CreateDirectMessageChannel.call do + Chat::CreateDirectMessageChannel.call(service_params) do on_success do render_serialized( result.channel, diff --git a/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb b/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb index a995084cce0..7e7e0700732 100644 --- a/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb +++ b/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb @@ -56,10 +56,12 @@ module Chat webhook.chat_channel.add(Discourse.system_user) Chat::CreateMessage.call( - chat_channel_id: webhook.chat_channel_id, - guardian: Discourse.system_user.guardian, - message: text, - incoming_chat_webhook: webhook, + service_params.merge( + chat_channel_id: webhook.chat_channel_id, + guardian: Discourse.system_user.guardian, + message: text, + incoming_chat_webhook: webhook, + ), ) do on_success { render json: success_json } on_failure { render(json: failed_json, status: 422) }