Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid throwing an error for successful delivery statuses #2080

Merged
merged 1 commit into from
Nov 20, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def message_params
def handle_statuses
statuses = @components[:statuses]
statuses.each do |status|
invalid_recipient_error = status[:errors].select { |error| error[:code].to_i.eql?(INVALID_MESSAGE_RECIPIENT_ERROR_CODE) }
invalid_recipient_error = status[:errors]&.select { |error| error[:code].to_i.eql?(INVALID_MESSAGE_RECIPIENT_ERROR_CODE) }
mark_inactive_contributor_inactive(status) if invalid_recipient_error.present?
handle_errors(status[:errors]) if status[:status].in?(UNSUCCESSFUL_DELIVERY)
end
Expand Down
26 changes: 26 additions & 0 deletions spec/requests/whats_app/three_sixty_dialog_webhook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,32 @@
end

describe 'statuses' do
context 'successful delivery' do
let(:successful_delivery) do
[{
'id' => 'valid_message_id',
'status' => 'delivered',
'timestamp' => '1732132030',
'recipient_id' => '49123456789',
'conversation' => {
'id' => 'valid_conversation_id', 'origin' => {
'type' => 'marketing'
}
},
'pricing' => {
'billable' => true, 'pricing_model' => 'CBP', 'category' => 'marketing'
}
}]
end

before { components[:statuses] = successful_delivery }

it 'is successful' do
subject.call
expect(response).to be_successful
end
end

context 'unsuccessful delivery' do
context 'failed delivery' do
let(:user) { create(:user, organizations: [organization]) }
Expand Down
Loading