mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Fix followers synchronization mechanism not working when URI has empty path (#16744)
Follow-up to #16510, forgot the controller exposing the actual followers…
This commit is contained in:
parent
8f7308da81
commit
e0af97164a
2 changed files with 5 additions and 3 deletions
|
@ -19,11 +19,11 @@ class ActivityPub::FollowersSynchronizationsController < ActivityPub::BaseContro
|
||||||
private
|
private
|
||||||
|
|
||||||
def uri_prefix
|
def uri_prefix
|
||||||
signed_request_account.uri[/http(s?):\/\/[^\/]+\//]
|
signed_request_account.uri[Account::URL_PREFIX_RE]
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_items
|
def set_items
|
||||||
@items = @account.followers.where(Account.arel_table[:uri].matches(uri_prefix + '%', false, true)).pluck(:uri)
|
@items = @account.followers.where(Account.arel_table[:uri].matches("#{Account.sanitize_sql_like(uri_prefix)}/%", false, true)).or(@account.followers.where(uri: uri_prefix)).pluck(:uri)
|
||||||
end
|
end
|
||||||
|
|
||||||
def collection_presenter
|
def collection_presenter
|
||||||
|
|
|
@ -5,11 +5,13 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController, type: :controll
|
||||||
let!(:follower_1) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/users/a') }
|
let!(:follower_1) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/users/a') }
|
||||||
let!(:follower_2) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/users/b') }
|
let!(:follower_2) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/users/b') }
|
||||||
let!(:follower_3) { Fabricate(:account, domain: 'foo.com', uri: 'https://foo.com/users/a') }
|
let!(:follower_3) { Fabricate(:account, domain: 'foo.com', uri: 'https://foo.com/users/a') }
|
||||||
|
let!(:follower_4) { Fabricate(:account, username: 'instance-actor', domain: 'example.com', uri: 'https://example.com') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
follower_1.follow!(account)
|
follower_1.follow!(account)
|
||||||
follower_2.follow!(account)
|
follower_2.follow!(account)
|
||||||
follower_3.follow!(account)
|
follower_3.follow!(account)
|
||||||
|
follower_4.follow!(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -45,7 +47,7 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController, type: :controll
|
||||||
|
|
||||||
it 'returns orderedItems with followers from example.com' do
|
it 'returns orderedItems with followers from example.com' do
|
||||||
expect(body[:orderedItems]).to be_an Array
|
expect(body[:orderedItems]).to be_an Array
|
||||||
expect(body[:orderedItems].sort).to eq [follower_1.uri, follower_2.uri]
|
expect(body[:orderedItems].sort).to eq [follower_4.uri, follower_1.uri, follower_2.uri]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns private Cache-Control header' do
|
it 'returns private Cache-Control header' do
|
||||||
|
|
Loading…
Reference in a new issue