diff --git a/app/models/concerns/smooch_messages.rb b/app/models/concerns/smooch_messages.rb index 4dd71298fe..313ac656d2 100644 --- a/app/models/concerns/smooch_messages.rb +++ b/app/models/concerns/smooch_messages.rb @@ -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 diff --git a/app/models/tipline_message.rb b/app/models/tipline_message.rb index 039440d792..e6d311e78a 100644 --- a/app/models/tipline_message.rb +++ b/app/models/tipline_message.rb @@ -32,8 +32,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 diff --git a/test/models/bot/smooch_test.rb b/test/models/bot/smooch_test.rb index 34eaf55de5..c587c90d6d 100644 --- a/test/models/bot/smooch_test.rb +++ b/test/models/bot/smooch_test.rb @@ -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!