remove.rb 802 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # frozen_string_literal: true
  2. class ActivityPub::Activity::Remove < ActivityPub::Activity
  3. def perform
  4. return if @json['target'].blank?
  5. case value_or_id(@json['target'])
  6. when @account.featured_collection_url
  7. case @object['type']
  8. when 'Hashtag'
  9. remove_featured_tags
  10. else
  11. remove_featured
  12. end
  13. end
  14. end
  15. private
  16. def remove_featured
  17. status = status_from_uri(object_uri)
  18. return unless !status.nil? && status.account_id == @account.id
  19. pin = StatusPin.find_by(account: @account, status: status)
  20. pin&.destroy!
  21. end
  22. def remove_featured_tags
  23. name = @object['name']&.delete_prefix('#')
  24. return if name.blank?
  25. featured_tag = FeaturedTag.by_name(name).find_by(account: @account)
  26. featured_tag&.destroy!
  27. end
  28. end