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

A couple of small fixes for the conversation history. #1696

Merged
merged 2 commits into from
Oct 17, 2023
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: 1 addition & 1 deletion app/models/concerns/smooch_messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def send_message_on_status_change(pm_id, status, request_actor_session_id = nil)
self.get_installation(self.installation_setting_id_keys, data['app_id']) if self.config.blank?
message = parent.team.get_status_message_for_language(status, data['language'])
unless message.blank?
response = self.send_message_to_user(data['authorId'], message)
response = self.send_message_to_user(data['authorId'], message, {}, false, true, 'status_change')
self.save_smooch_response(response, parent, data['received'].to_i, 'fact_check_status', data['language'], { message: message })
requestors_count += 1
end
Expand Down
3 changes: 3 additions & 0 deletions app/models/tipline_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ def media_url
if self.direction == 'incoming'
media_url = payload.dig('messages', 0, 'mediaUrl')
elsif self.direction == 'outgoing'
# WhatsApp Cloud API template
header = payload.dig('override', 'whatsapp', 'payload', 'interactive', 'header')
media_url = header[header['type']]['link'] unless header.nil?
# WhatsApp template on Smooch
media_url ||= payload.dig('text').to_s.match(/header_image=\[\[([^\]]+)\]\]/).to_a.last
end
media_url || payload['mediaUrl']
end
Expand Down
2 changes: 1 addition & 1 deletion test/models/bot/smooch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ def teardown
}.to_json
assert Bot::Smooch.run(payload)
pm = ProjectMedia.last
Bot::Smooch.stubs(:send_message_to_user).with(uid, 'Custom').once
Bot::Smooch.stubs(:send_message_to_user).with(uid, 'Custom', {}, false, true, 'status_change').once
s = pm.annotations.where(annotation_type: 'verification_status').last.load
s.status = '2'
s.save!
Expand Down
Loading