]> cat aescling's git repositories - mastodon.git/commitdiff
When follow is removed, remove endorsement (#8149)
authorEugen Rochko <eugen@zeonfederated.com>
Thu, 9 Aug 2018 13:24:29 +0000 (15:24 +0200)
committerGitHub <noreply@github.com>
Thu, 9 Aug 2018 13:24:29 +0000 (15:24 +0200)
app/models/follow.rb

index eaf8445f3bfb0c9243c6b1ebb4321e1bfc7bc8a5..3fce14b9ac5debdae1ae1811aacdcf07dd1ecdc3 100644 (file)
@@ -33,10 +33,15 @@ class Follow < ApplicationRecord
   end
 
   before_validation :set_uri, only: :create
+  after_destroy :remove_endorsements
 
   private
 
   def set_uri
     self.uri = ActivityPub::TagManager.instance.generate_uri_for(self) if uri.nil?
   end
+
+  def remove_endorsements
+    AccountPin.where(target_account_id: target_account_id, account_id: account_id).delete_all
+  end
 end