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

Only deliver fact-check title and URL for Facebook Messenger tipline search results #1801

Merged
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
7 changes: 4 additions & 3 deletions app/models/concerns/smooch_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def search(app_id, uid, language, message, team_id, workflow, provider = nil)
self.bundle_messages(uid, '', app_id, 'default_requests', nil, true)
self.send_final_message_to_user(uid, self.get_custom_string('search_no_results', language), workflow, language, 'no_results')
else
self.send_search_results_to_user(uid, results, team_id)
self.send_search_results_to_user(uid, results, team_id, platform)
sm.go_to_search_result
self.save_search_results_for_user(uid, results.map(&:id))
self.delay_for(1.second, { queue: 'smooch_priority' }).ask_for_feedback_when_all_search_results_are_received(app_id, language, workflow, uid, platform, 1)
Expand Down Expand Up @@ -217,7 +217,7 @@ def search_by_keywords_for_similar_published_fact_checks(words, after, team_ids,
results
end

def send_search_results_to_user(uid, results, team_id)
def send_search_results_to_user(uid, results, team_id, platform)
team = Team.find(team_id)
redis = Redis.new(REDIS_CONFIG)
language = self.get_user_language(uid)
Expand All @@ -230,7 +230,8 @@ def send_search_results_to_user(uid, results, team_id)
end
reports.reject{ |r| r.blank? }.each do |report|
response = nil
response = self.send_message_to_user(uid, report.report_design_text, {}, false, true, 'search_result') if report.report_design_field_value('use_text_message')
no_body = (platform == 'Facebook Messenger')
response = self.send_message_to_user(uid, report.report_design_text(nil, no_body), {}, false, true, 'search_result') if report.report_design_field_value('use_text_message')
response = self.send_message_to_user(uid, '', { 'type' => 'image', 'mediaUrl' => report.report_design_image_url }, false, true, 'search_result') if !report.report_design_field_value('use_text_message') && report.report_design_field_value('use_visual_card')
id = self.get_id_from_send_response(response)
redis.rpush("smooch:search:#{uid}", id) unless id.blank?
Expand Down
4 changes: 2 additions & 2 deletions config/initializers/report_designer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ def report_design_text_footer(language)
footer.join("\n")
end

def report_design_text(language = nil)
def report_design_text(language = nil, hide_body = false)
if self.annotation_type == 'report_design'
team = self.annotated.team
text = []
title = self.report_design_field_value('title')
text << "*#{title.strip}*" unless title.blank?
text << self.report_design_field_value('text').to_s
text << self.report_design_field_value('text').to_s unless hide_body
url = self.report_design_field_value('published_article_url')
text << url unless url.blank?
text = text.collect do |part|
Expand Down
Loading