Federate new profile settings (#38314)
This commit is contained in:
parent
b9388bed73
commit
ca08c040b0
@ -25,6 +25,12 @@ module ContextHelper
|
|||||||
voters_count: { 'toot' => 'http://joinmastodon.org/ns#', 'votersCount' => 'toot:votersCount' },
|
voters_count: { 'toot' => 'http://joinmastodon.org/ns#', 'votersCount' => 'toot:votersCount' },
|
||||||
suspended: { 'toot' => 'http://joinmastodon.org/ns#', 'suspended' => 'toot:suspended' },
|
suspended: { 'toot' => 'http://joinmastodon.org/ns#', 'suspended' => 'toot:suspended' },
|
||||||
attribution_domains: { 'toot' => 'http://joinmastodon.org/ns#', 'attributionDomains' => { '@id' => 'toot:attributionDomains', '@type' => '@id' } },
|
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' },
|
quote_requests: { 'QuoteRequest' => 'https://w3id.org/fep/044f#QuoteRequest' },
|
||||||
quotes: {
|
quotes: {
|
||||||
'quote' => 'https://w3id.org/fep/044f#quote',
|
'quote' => 'https://w3id.org/fep/044f#quote',
|
||||||
|
|||||||
@ -8,7 +8,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
|||||||
|
|
||||||
context_extensions :manually_approves_followers, :featured, :also_known_as,
|
context_extensions :manually_approves_followers, :featured, :also_known_as,
|
||||||
:moved_to, :property_value, :discoverable, :suspended,
|
: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?
|
context_extensions :interaction_policies if Mastodon::Feature.collections_enabled?
|
||||||
|
|
||||||
@ -16,7 +16,10 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
|||||||
:inbox, :outbox, :featured, :featured_tags,
|
:inbox, :outbox, :featured, :featured_tags,
|
||||||
:preferred_username, :name, :summary,
|
:preferred_username, :name, :summary,
|
||||||
:url, :manually_approves_followers,
|
: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 :interaction_policy, if: -> { Mastodon::Feature.collections_enabled? }
|
||||||
attribute :featured_collections, if: -> { Mastodon::Feature.collections_enabled? }
|
attribute :featured_collections, if: -> { Mastodon::Feature.collections_enabled? }
|
||||||
|
|||||||
@ -135,6 +135,9 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||||||
@account.discoverable = @json['discoverable'] || false
|
@account.discoverable = @json['discoverable'] || false
|
||||||
@account.indexable = @json['indexable'] || false
|
@account.indexable = @json['indexable'] || false
|
||||||
@account.memorial = @json['memorial'] || 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) }
|
@account.attribution_domains = as_array(@json['attributionDomains'] || []).take(Account::ATTRIBUTION_DOMAINS_HARD_LIMIT).map { |item| value_or_id(item) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -114,6 +114,30 @@ RSpec.describe ActivityPub::ProcessAccountService do
|
|||||||
end
|
end
|
||||||
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
|
context 'with inlined feature collection' do
|
||||||
let(:payload) do
|
let(:payload) do
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user