From 48a0fa1d670474b3295014d820a56d31ed1ccc79 Mon Sep 17 00:00:00 2001 From: Muhsin <12408980+muhsin-k@users.noreply.github.com> Date: Wed, 3 Jun 2026 20:10:45 +0400 Subject: [PATCH] fix(app-store): reject unsupported review responses --- .../app_store/send_on_app_store_service.rb | 1 + .../send_on_app_store_service_spec.rb | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/services/app_store/send_on_app_store_service.rb b/app/services/app_store/send_on_app_store_service.rb index 9e52b4b1b..b5b004e20 100644 --- a/app/services/app_store/send_on_app_store_service.rb +++ b/app/services/app_store/send_on_app_store_service.rb @@ -16,6 +16,7 @@ class AppStore::SendOnAppStoreService < Base::SendOnChannelService end def validate_message_support! + raise 'Only outgoing text messages are supported for App Store reviews.' unless message.outgoing? && message.text? raise 'Sending attachments is not supported for App Store reviews.' if message.attachments.any? end diff --git a/spec/services/app_store/send_on_app_store_service_spec.rb b/spec/services/app_store/send_on_app_store_service_spec.rb index bb88d7f25..3ac7a25da 100644 --- a/spec/services/app_store/send_on_app_store_service_spec.rb +++ b/spec/services/app_store/send_on_app_store_service_spec.rb @@ -79,6 +79,30 @@ RSpec.describe AppStore::SendOnAppStoreService do expect(exception_tracker).to have_received(:capture_exception) end + it 'marks the message as failed when the message is not plain outgoing text' do + message = create( + :message, + message_type: :outgoing, + content_type: :input_csat, + inbox: inbox, + conversation: conversation, + account: inbox.account, + content: 'Please rate this conversation' + ) + + allow(channel).to receive(:reply_to_review) + + described_class.new(message: message).perform + + expect(channel).not_to have_received(:reply_to_review) + expect(Messages::StatusUpdateService).to have_received(:new).with( + message, + 'failed', + 'Only outgoing text messages are supported for App Store reviews.' + ) + expect(exception_tracker).to have_received(:capture_exception) + end + it 'marks the message as failed when the feature is disabled' do account.disable_features!(:channel_app_store) message = create(:message, message_type: :outgoing, inbox: inbox, conversation: conversation, account: inbox.account, content: 'Thanks')