Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/controllers/api/v1/bulk_actions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ class Api::V1::BulkActionsController < Api::V1::BaseController

def create
if type_matches?
::BulkActionsJob.perform_now(
result = ::BulkActionsJob.perform_now(
user: current_user,
params: permitted_params
)

success_response(
data: nil,
data: result,
message: 'Bulk action completed successfully',
status: :created
)
Expand Down
9 changes: 9 additions & 0 deletions app/jobs/bulk_actions_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def perform(account: nil, params:, user:)
def bulk_update
if @params[:type] == 'Contact'
bulk_contact_update
{ success_ids: [], failed_ids: [] }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): The Contact branch now returns an always-empty result, which is inconsistent with conversation updates and likely breaks result reporting.

For the Contact path, bulk_update now always returns { success_ids: [], failed_ids: [] }, while the conversation path returns real IDs from bulk_conversation_update. As a result, the client will see empty arrays even when Contact updates succeed or fail. Either have bulk_contact_update return a similar success/failed ID structure and propagate it, or return nil and let the controller branch by type so it doesn’t promise per-record results for contacts.

else
bulk_remove_labels
bulk_conversation_update
Expand All @@ -35,11 +36,19 @@ def bulk_contact_update

def bulk_conversation_update
params = available_params(@params)
success_ids = []
failed_ids = []

records.each do |conversation|
bulk_add_labels(conversation)
bulk_snoozed_until(conversation)
conversation.update!(params) if params
success_ids << conversation.display_id
rescue StandardError
failed_ids << conversation.display_id
end

{ success_ids: success_ids, failed_ids: failed_ids }
end

def bulk_remove_labels
Expand Down