mirror of
https://github.com/mastodon/mastodon.git
synced 2026-06-15 12:15:09 -05:00
Some checks failed
Check i18n / check-i18n (push) Waiting to run
Chromatic / Check for relevant changes (push) Waiting to run
Chromatic / Run Chromatic (push) Blocked by required conditions
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / test (3.4) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.4) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.19.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Bundler Audit / security (push) Has been cancelled
Haml Linting / lint (push) Has been cancelled
Ruby Linting / lint (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
47 lines
1.1 KiB
Ruby
47 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class ActivityPub::Activity::Add < 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'
|
|
add_featured_tags
|
|
else
|
|
add_featured
|
|
end
|
|
when @account.collections_url
|
|
add_collection
|
|
else
|
|
@collection = @account.collections.find_by(uri: value_or_id(@json['target']))
|
|
add_collection_item if @collection
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def add_featured
|
|
status = status_from_object
|
|
|
|
return unless !status.nil? && status.account_id == @account.id && !@account.pinned?(status)
|
|
|
|
StatusPin.create!(account: @account, status: status)
|
|
end
|
|
|
|
def add_featured_tags
|
|
name = @object['name']&.delete_prefix('#')
|
|
|
|
FeaturedTag.create!(account: @account, name: name) if name.present?
|
|
end
|
|
|
|
def add_collection
|
|
ActivityPub::ProcessFeaturedCollectionService.new.call(@account, @object)
|
|
end
|
|
|
|
def add_collection_item
|
|
ActivityPub::ProcessFeaturedItemService.new.call(@collection, @object)
|
|
end
|
|
end
|