When follow is removed, remove endorsement (#8149)
This commit is contained in:
		
							parent
							
								
									9e8366d4cb
								
							
						
					
					
						commit
						d0b6cbfb92
					
				
					 1 changed files with 5 additions and 0 deletions
				
			
		| 
						 | 
					@ -33,10 +33,15 @@ class Follow < ApplicationRecord
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_validation :set_uri, only: :create
 | 
					  before_validation :set_uri, only: :create
 | 
				
			||||||
 | 
					  after_destroy :remove_endorsements
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private
 | 
					  private
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def set_uri
 | 
					  def set_uri
 | 
				
			||||||
    self.uri = ActivityPub::TagManager.instance.generate_uri_for(self) if uri.nil?
 | 
					    self.uri = ActivityPub::TagManager.instance.generate_uri_for(self) if uri.nil?
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def remove_endorsements
 | 
				
			||||||
 | 
					    AccountPin.where(target_account_id: target_account_id, account_id: account_id).delete_all
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue