Skip to content

Commit

Permalink
Adjust Smooch Bot provider when tipline is running both CAPI and Smoo…
Browse files Browse the repository at this point in the history
…ch. (#2004)

Fixes CV2-5127.
  • Loading branch information
caiosba authored Aug 27, 2024
1 parent 72503a0 commit c1c9b20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/concerns/smooch_resend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def message_tags_payload(text, image = nil)
def resend_facebook_messenger_message_after_window(message, original)
original = JSON.parse(original) unless original.blank?
uid = message['appUser']['_id']
RequestStore.store[:smooch_bot_provider] = 'ZENDESK'

return self.resend_facebook_messenger_report_after_window(message, original) if original&.dig('fallback_template') =~ /report/

Expand All @@ -184,6 +185,7 @@ def resend_facebook_messenger_message_after_window(message, original)
end

def resend_facebook_messenger_report_after_window(message, original)
RequestStore.store[:smooch_bot_provider] = 'ZENDESK'
pm = ProjectMedia.where(id: original['project_media_id']).last
report = self.get_report_data_to_be_resent(message, original)
unless report.nil?
Expand Down
1 change: 1 addition & 0 deletions app/workers/tipline_newsletter_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def perform(team_id, language, job_created_at = 0)
begin
RequestStore.store[:smooch_bot_platform] = ts.platform
Bot::Smooch.get_installation('team_bot_installation_id', tbi.id) { |i| i.id == tbi.id }
RequestStore.store[:smooch_bot_provider] = 'ZENDESK' if ts.platform != 'WhatsApp' # Adjustment for tiplines running CAPI and Smooch at the same time

response = (ts.platform == 'WhatsApp' ? Bot::Smooch.send_message_to_user(ts.uid, newsletter.format_as_template_message, {}, false, true, 'newsletter') : Bot::Smooch.send_message_to_user(ts.uid, *newsletter.format_as_tipline_message))

Expand Down

0 comments on commit c1c9b20

Please sign in to comment.