~cytrogen/masto-fe

ref: 027c1bef8d0314dfd800d345d322d8023f2383f7 masto-fe/app/lib/activitypub/activity/remove.rb -rw-r--r-- 802 bytes
027c1bef — renovate[bot] Update dependency active_model_serializers to v0.10.14 (#27303) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

class ActivityPub::Activity::Remove < ActivityPub::Activity
  def perform
    return if @json['target'].blank?

    case value_or_id(@json['target'])
    when @account.featured_collection_url
      case @object['type']
      when 'Hashtag'
        remove_featured_tags
      else
        remove_featured
      end
    end
  end

  private

  def remove_featured
    status = status_from_uri(object_uri)

    return unless !status.nil? && status.account_id == @account.id

    pin = StatusPin.find_by(account: @account, status: status)
    pin&.destroy!
  end

  def remove_featured_tags
    name = @object['name']&.delete_prefix('#')

    return if name.blank?

    featured_tag = FeaturedTag.by_name(name).find_by(account: @account)
    featured_tag&.destroy!
  end
end