mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Store a remote actor's featuredCollections URI (#38166)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
# avatar_remote_url :string
|
||||
# avatar_storage_schema_version :integer
|
||||
# avatar_updated_at :datetime
|
||||
# collections_url :string
|
||||
# discoverable :boolean
|
||||
# display_name :string default(""), not null
|
||||
# domain :string
|
||||
|
||||
@@ -125,6 +125,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
||||
|
||||
def set_immediate_attributes!
|
||||
@account.featured_collection_url = valid_collection_uri(@json['featured'])
|
||||
@account.collections_url = valid_collection_uri(@json['featuredCollections'])
|
||||
@account.display_name = (@json['name'] || '')[0...(Account::DISPLAY_NAME_LENGTH_HARD_LIMIT)]
|
||||
@account.note = (@json['summary'] || '')[0...(Account::NOTE_LENGTH_HARD_LIMIT)]
|
||||
@account.locked = @json['manuallyApprovesFollowers'] || false
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddCollectionsURLToAccounts < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
add_column :accounts, :collections_url, :string
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_03_10_095021) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_03_11_152331) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
|
||||
@@ -162,6 +162,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_03_10_095021) do
|
||||
t.string "avatar_remote_url"
|
||||
t.integer "avatar_storage_schema_version"
|
||||
t.datetime "avatar_updated_at", precision: nil
|
||||
t.string "collections_url"
|
||||
t.datetime "created_at", precision: nil, null: false
|
||||
t.boolean "discoverable"
|
||||
t.string "display_name", default: "", null: false
|
||||
|
||||
@@ -63,6 +63,34 @@ RSpec.describe ActivityPub::ProcessAccountService do
|
||||
end
|
||||
end
|
||||
|
||||
context 'with collection URIs' do
|
||||
let(:payload) do
|
||||
{
|
||||
'id' => 'https://foo.test',
|
||||
'type' => 'Actor',
|
||||
'inbox' => 'https://foo.test/inbox',
|
||||
'featured' => 'https://foo.test/featured',
|
||||
'followers' => 'https://foo.test/followers',
|
||||
'following' => 'https://foo.test/following',
|
||||
'featuredCollections' => 'https://foo.test/featured_collections',
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, %r{^https://foo\.test/follow})
|
||||
.to_return(status: 200, body: '', headers: {})
|
||||
end
|
||||
|
||||
it 'parses and sets the URIs' do
|
||||
account = subject.call('alice', 'example.com', payload)
|
||||
|
||||
expect(account.featured_collection_url).to eq 'https://foo.test/featured'
|
||||
expect(account.followers_url).to eq 'https://foo.test/followers'
|
||||
expect(account.following_url).to eq 'https://foo.test/following'
|
||||
expect(account.collections_url).to eq 'https://foo.test/featured_collections'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with attribution domains' do
|
||||
let(:payload) do
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user