about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-08-09 15:24:29 +0200
committerGitHub <noreply@github.com>2018-08-09 15:24:29 +0200
commitaff6a15061de203842653d680047322277dc7af6 (patch)
tree613ceb741cd6397d990f8f041b3d3ff6710847ec
parent0dcc1950d14cc4a7725ea1572d253c538a1f74e8 (diff)
When follow is removed, remove endorsement (#8149)
-rw-r--r--app/models/follow.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/follow.rb b/app/models/follow.rb
index eaf8445f3..3fce14b9a 100644
--- a/app/models/follow.rb
+++ b/app/models/follow.rb
@@ -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