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

Adjust Smooch Bot provider when tipline is running both CAPI and Smooch. #2004

Merged
merged 1 commit into from
Aug 27, 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
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
Loading