Skip to content

Commit

Permalink
CV2-5273: fix sentry issue (#2041)
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Sep 17, 2024
1 parent 743c4b2 commit 8881e92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion app/models/bot/smooch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,9 @@ def self.save_text_message(message)
end
else
extra = { url: link.url }
pm = ProjectMedia.joins(:media).where('medias.url' => link.url, 'project_medias.team_id' => team.id).last
# Normalized url before query DB
url_from_pender = Link.normalized(link.url, team.get_pender_key)
pm = ProjectMedia.joins(:media).where('medias.url' => url_from_pender, 'project_medias.team_id' => team.id).last
end
if pm.nil?
type = link.nil? ? 'Claim' : 'Link'
Expand Down
15 changes: 9 additions & 6 deletions app/models/concerns/smooch_messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,15 @@ def relate_item_and_caption(message, associated, app_id, author, request_type, a
target = self.create_project_media_from_message(message)
unless target.nil?
smoooch_post_save_message_actions(message, target, app_id, author, request_type, associated_obj)
r = Relationship.new
r.skip_check_ability = true
r.relationship_type = Relationship.suggested_type
r.source_id = associated.id
r.target_id = target.id
r.save!
r_exists = Relationship.where(source_id: associated.id, target_id: target.id).exists?
unless r_exists
r = Relationship.new
r.skip_check_ability = true
r.relationship_type = Relationship.suggested_type
r.source_id = associated.id
r.target_id = target.id
r.save!
end
end
end

Expand Down

0 comments on commit 8881e92

Please sign in to comment.