Skip to content

Commit

Permalink
Merge branch 'develop' into fix/CV2-6125-has-claim-filter-does-not-wo…
Browse files Browse the repository at this point in the history
…rk-as-expected
  • Loading branch information
melsawy committed Feb 6, 2025
2 parents dbdf4c2 + 7038516 commit 2141cfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/smooch_messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ def default_archived_flag
end

def save_message(message_json, app_id, author = nil, request_type = 'default_requests', associated_id = nil, associated_class = nil)
# associated: is the the "first media" and will be the source of the Relationship
# associated_obj: is used for TiplineRequest (smooch_resource_id field)
# associated: is the the "first media" and will be the source of the Relationship
# associated_obj: is used for TiplineRequest (smooch_resource_id field)
message = JSON.parse(message_json)
return if TiplineRequest.where(smooch_message_id: message['_id']).exists?
associated_obj = nil
Expand Down
4 changes: 4 additions & 0 deletions app/models/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ def create_or_update_parent_id
end

def self.create_unless_exists(source_id, target_id, relationship_type, options = {})
# Verify that the target is not part of another source; in this case, we should return the existing relationship.
r = Relationship.where(target_id: target_id).where.not(source_id: source_id).last
return r unless r.nil?
# otherwise we should get the existing relationship based on source, target and type
r = Relationship.where(source_id: source_id, target_id: target_id).where('relationship_type = ?', relationship_type.to_yaml).last
exception_message = nil
exception_class = nil
Expand Down

0 comments on commit 2141cfa

Please sign in to comment.