]> cat aescling's git repositories - mastodon.git/commitdiff
Fix more subtle bugs with first_or_create
authorEugen Rochko <eugen@zeonfederated.com>
Fri, 18 Mar 2016 23:02:39 +0000 (00:02 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 18 Mar 2016 23:02:39 +0000 (00:02 +0100)
app/services/process_interaction_service.rb
app/services/process_mentions_service.rb

index 43c8ca4fde85d033f431ca13d6bce8a7375bfb95..cdc72008390dcb08423e083c4d0086cdea593498 100644 (file)
@@ -62,7 +62,7 @@ class ProcessInteractionService < BaseService
   end
 
   def favourite!(xml, from_account)
-    status(xml).favourites.first_or_create!(account: from_account)
+    status(xml).favourites.where(account: from_account).first_or_create!(account: from_account)
   end
 
   def add_post!(body, account)
index 760fdcf15dd8d3220494355f2668e97e9d49b030..6e92d16b45bd717a274ab54faa4231d8c954cd2f 100644 (file)
@@ -14,7 +14,7 @@ class ProcessMentionsService < BaseService
         mentioned_account = follow_remote_account_service.("#{match.first}")
       end
 
-      mentioned_account.mentions.first_or_create(status: status)
+      mentioned_account.mentions.where(status: status).first_or_create(status: status)
     end
 
     status.mentions.each do |mentioned_account|