Skip to content

Commit

Permalink
move return back, change associated_obj to associated
Browse files Browse the repository at this point in the history
There aren't any changes to associated before we try to create the
Relationship, so I think it's ok to do the early return earlier.

We create the relationship between associated and target, not associated_obj,
so we should check it instead.
  • Loading branch information
vasconsaurus committed Dec 18, 2024
1 parent 37f1897 commit 1faac3d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/concerns/smooch_messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ def smooch_post_save_message_actions(message, associated, app_id, author, reques
end

def smooch_relate_items_for_same_message(message, associated, app_id, author, request_type, associated_obj)
return unless associated.is_a?(ProjectMedia)
if !message['caption'].blank?
# Check if message contains caption then create an item and force relationship
self.relate_item_and_text(message, associated, app_id, author, request_type, associated_obj, Relationship.confirmed_type)
Expand All @@ -456,7 +457,6 @@ def relate_item_and_text(message, associated, app_id, author, request_type, asso
target = self.create_project_media_from_message(message)
unless target.nil?
smooch_post_save_message_actions(message, target, app_id, author, request_type, associated_obj)
return unless associated_obj.is_a?(ProjectMedia)
Relationship.create_unless_exists(associated.id, target.id, relationship_type)
end
end
Expand Down

0 comments on commit 1faac3d

Please sign in to comment.