Federate new profile settings (#38314)

This commit is contained in:
Claire
2026-03-24 10:20:17 +01:00
committed by GitHub
parent b9388bed73
commit ca08c040b0
4 changed files with 38 additions and 2 deletions

View File

@@ -25,6 +25,12 @@ module ContextHelper
voters_count: { 'toot' => 'http://joinmastodon.org/ns#', 'votersCount' => 'toot:votersCount' },
suspended: { 'toot' => 'http://joinmastodon.org/ns#', 'suspended' => 'toot:suspended' },
attribution_domains: { 'toot' => 'http://joinmastodon.org/ns#', 'attributionDomains' => { '@id' => 'toot:attributionDomains', '@type' => '@id' } },
profile_settings: {
'toot' => 'http://joinmastodon.org/ns#',
'showFeatured' => 'toot:showFeatured',
'showMedia' => 'toot:showMedia',
'showRepliesInMedia' => 'toot:showRepliesInMedia',
},
quote_requests: { 'QuoteRequest' => 'https://w3id.org/fep/044f#QuoteRequest' },
quotes: {
'quote' => 'https://w3id.org/fep/044f#quote',

View File

@@ -8,7 +8,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
context_extensions :manually_approves_followers, :featured, :also_known_as,
:moved_to, :property_value, :discoverable, :suspended,
:memorial, :indexable, :attribution_domains
:memorial, :indexable, :attribution_domains, :profile_settings
context_extensions :interaction_policies if Mastodon::Feature.collections_enabled?
@@ -16,7 +16,10 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
:inbox, :outbox, :featured, :featured_tags,
:preferred_username, :name, :summary,
:url, :manually_approves_followers,
:discoverable, :indexable, :published, :memorial
:discoverable, :indexable, :published, :memorial,
:show_featured, :show_media
attribute :show_media_replies, key: :show_replies_in_media
attribute :interaction_policy, if: -> { Mastodon::Feature.collections_enabled? }
attribute :featured_collections, if: -> { Mastodon::Feature.collections_enabled? }

View File

@@ -135,6 +135,9 @@ class ActivityPub::ProcessAccountService < BaseService
@account.discoverable = @json['discoverable'] || false
@account.indexable = @json['indexable'] || false
@account.memorial = @json['memorial'] || false
@account.show_featured = @json['showFeatured'] if @json.key?('showFeatured')
@account.show_media = @json['showMedia'] if @json.key?('showMedia')
@account.show_media_replies = @json['showRepliesInMedia'] if @json.key?('showRepliesInMedia')
@account.attribution_domains = as_array(@json['attributionDomains'] || []).take(Account::ATTRIBUTION_DOMAINS_HARD_LIMIT).map { |item| value_or_id(item) }
end

View File

@@ -114,6 +114,30 @@ RSpec.describe ActivityPub::ProcessAccountService do
end
end
context 'with profile settings' do
let(:payload) do
{
id: 'https://foo.test',
type: 'Actor',
inbox: 'https://foo.test/inbox',
showMedia: true,
showRepliesInMedia: false,
showFeatured: false,
}.with_indifferent_access
end
it 'sets the profile settings as expected' do
account = subject.call('alice', 'example.com', payload)
expect(account)
.to have_attributes(
show_media: true,
show_media_replies: false,
show_featured: false
)
end
end
context 'with inlined feature collection' do
let(:payload) do
{