Skip to content

Commit

Permalink
Properly handle stickers as unsupported content (#2064)
Browse files Browse the repository at this point in the history
Fixes #2063
  • Loading branch information
mattwr18 authored Oct 15, 2024
1 parent 438b302 commit c8dff37
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ThreeSixtyDialogInbound
REQUEST_TO_RECEIVE_MESSAGE = :request_to_receive_message
UNSUBSCRIBE_CONTRIBUTOR = :unsubscribe_contributor
RESUBSCRIBE_CONTRIBUTOR = :resubscribe_contributor
UNSUPPORTED_CONTENT_TYPES = %w[location contacts application].freeze
UNSUPPORTED_CONTENT_TYPES = %w[location contacts application sticker].freeze

attr_reader :sender, :text, :message, :organization

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def message_params
{ contacts: [{ org: {} }, { addresses: [] }, { emails: [] }, { ims: [] },
{ phones: %i[phone type wa_id] }, { urls: [] },
{ name: %i[first_name formatted_name last_name] }] },
{ sticker: %i[id mime_type sha256 animated] },
{ context: %i[from id] }],
statuses: [:id, :status, :timestamp, :expiration_timestamp, :recipient_id,
{ conversation: [:id, { origin: [:type] }] },
Expand Down
20 changes: 20 additions & 0 deletions spec/adapters/whats_app_adapter/three_sixty_dialog_inbound_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,26 @@

it { should have_received(:call).with(contributor) }
end

context 'sticker' do
let(:sticker) do
{
mime_type: 'image/webp',
sha256: 'sha256_hash',
id: 'some_valid_id',
animated: false
}
end

before do
message[:type] = 'sticker'
message[:sticker] = sticker
end

it 'triggers the unsupported content callback' do
expect(subject).to have_received(:call).with(contributor)
end
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,26 @@
expect { subject.call }.to have_enqueued_job(WhatsAppAdapter::ThreeSixtyDialogOutbound::Text).with(text_payload)
end
end

context 'stickers' do
let(:sticker) do
{
mime_type: 'image/webp',
sha256: 'sha256_hash',
id: 'some_valid_id',
animated: false
}
end

before do
message[:type] = 'sticker'
message[:sticker] = sticker
end

it 'sends a message to contributor to let them know the message type is not supported' do
expect { subject.call }.to have_enqueued_job(WhatsAppAdapter::ThreeSixtyDialogOutbound::Text).with(text_payload)
end
end
end
end
end
Expand Down

0 comments on commit c8dff37

Please sign in to comment.