Skip to content

Commit

Permalink
Do not send a report to a tipline user for relationships created by A…
Browse files Browse the repository at this point in the history
…legre Bot

Expand the current condition so that reports are not sent for relationships saved by not only by Smooch Bot, but also by Alegre Bot. The rationale is that medias are created only through tipline requests, so they already received search results and gave feedback, so they don't need to receive additional reports.

Fixes CV2-4068.
  • Loading branch information
caiosba committed Dec 5, 2023
1 parent 434fcdb commit 1bbada2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/models/bot/smooch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def suggestion_accepted?

def self.inherit_status_and_send_report(rid)
relationship = Relationship.find_by_id(rid)
# A relationship created by the Smooch Bot is related to search results, so the user has already received the report as a search result
return if relationship&.user && relationship.user == BotUser.smooch_user
unless relationship.nil?
# A relationship created by the Smooch Bot or Alegre Bot is related to search results, so the user has already received the report as a search result
return if [BotUser.smooch_user&.id, BotUser.alegre_user&.id].include?(relationship.user_id)
target = relationship.target
parent = relationship.source
if ::Bot::Smooch.team_has_smooch_bot_installed(target) && relationship.is_confirmed?
Expand Down
2 changes: 1 addition & 1 deletion test/models/bot/smooch_2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def teardown

child = create_project_media project: @project
create_dynamic_annotation annotation_type: 'smooch', annotated: child, set_fields: { smooch_message_id: random_string, smooch_data: { app_id: @app_id, authorId: random_string, language: 'en' }.to_json }.to_json
r = create_relationship source_id: parent.id, target_id: child.id, relationship_type: Relationship.confirmed_type
r = create_relationship source_id: parent.id, target_id: child.id, relationship_type: Relationship.confirmed_type, user: create_user
s = child.annotations.where(annotation_type: 'verification_status').last.load
assert_equal 'verified', s.status

Expand Down

0 comments on commit 1bbada2

Please sign in to comment.