mirror of
https://github.com/mastodon/mastodon.git
synced 2025-10-05 16:42:47 +00:00
Fix followers synchronization for local numeric AP ID followers
Some checks are pending
Chromatic / Run Chromatic (push) Waiting to run
Some checks are pending
Chromatic / Run Chromatic (push) Waiting to run
This commit is contained in:
parent
7dfbcbafc1
commit
ce0d389811
|
@ -215,9 +215,8 @@ module Account::Interactions
|
|||
def local_followers_hash
|
||||
Rails.cache.fetch("followers_hash:#{id}:local") do
|
||||
digest = "\x00" * 32
|
||||
# TODO
|
||||
followers.where(domain: nil).pluck_each('false as numeric_ap_id', :id, :username) do |numeric_ap_id, id, username|
|
||||
uri = numeric_ap_id ? ActivityPub::TagManager.instance.uri_for_account_id(id) : ActivityPub::TagManager.instance.uri_for_username(username)
|
||||
followers.where(domain: nil).pluck_each(:id_scheme, :id, :username) do |id_scheme, id, username|
|
||||
uri = id_scheme == 'numeric_ap_id' ? ActivityPub::TagManager.instance.uri_for_account_id(id) : ActivityPub::TagManager.instance.uri_for_username(username)
|
||||
Xorcist.xor!(digest, Digest::SHA256.digest(uri))
|
||||
end
|
||||
digest.unpack1('H*')
|
||||
|
|
|
@ -563,6 +563,22 @@ RSpec.describe Account::Interactions do
|
|||
me.follow!(remote_alice)
|
||||
expect(remote_alice.local_followers_hash).to eq Digest::SHA256.hexdigest(ActivityPub::TagManager.instance.uri_for(me))
|
||||
end
|
||||
|
||||
context 'when using numeric ID based scheme' do
|
||||
let(:me) { Fabricate(:account, username: 'Me', id_scheme: :numeric_ap_id) }
|
||||
|
||||
it 'returns correct hash for local users' do
|
||||
expect(remote_alice.local_followers_hash).to eq Digest::SHA256.hexdigest(ActivityPub::TagManager.instance.uri_for(me))
|
||||
end
|
||||
|
||||
it 'invalidates cache as needed when removing or adding followers' do
|
||||
expect(remote_alice.local_followers_hash).to eq Digest::SHA256.hexdigest(ActivityPub::TagManager.instance.uri_for(me))
|
||||
me.unfollow!(remote_alice)
|
||||
expect(remote_alice.local_followers_hash).to eq '0000000000000000000000000000000000000000000000000000000000000000'
|
||||
me.follow!(remote_alice)
|
||||
expect(remote_alice.local_followers_hash).to eq Digest::SHA256.hexdigest(ActivityPub::TagManager.instance.uri_for(me))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'muting an account' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user