Skip to content

Commit aa21100

Browse files
authored
Fix URI generation for reblogs by accounts with numerical AP ids (mastodon#37415)
1 parent bdcdd53 commit aa21100

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

app/lib/activitypub/tag_manager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def uri_for(target)
5050
context_url(target) unless target.parent_account_id.nil? || target.parent_status_id.nil?
5151
when :note, :comment, :activity
5252
if target.account.numeric_ap_id?
53-
return activity_ap_account_status_url(target.account, target) if target.reblog?
53+
return activity_ap_account_status_url(target.account.id, target) if target.reblog?
5454

5555
ap_account_status_url(target.account.id, target)
5656
else

spec/lib/activitypub/tag_manager_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,28 @@
128128
.to eq("#{host_prefix}/ap/users/#{status.account.id}/statuses/#{status.id}")
129129
end
130130
end
131+
132+
context 'with a reblog' do
133+
let(:status) { Fabricate(:status, account:, reblog: Fabricate(:status)) }
134+
135+
context 'when using a numeric ID based scheme' do
136+
let(:account) { Fabricate(:account, id_scheme: :numeric_ap_id) }
137+
138+
it 'returns a string starting with web domain and with the expected path' do
139+
expect(subject.uri_for(status))
140+
.to eq("#{host_prefix}/ap/users/#{status.account.id}/statuses/#{status.id}/activity")
141+
end
142+
end
143+
144+
context 'when using the legacy username based scheme' do
145+
let(:account) { Fabricate(:account, id_scheme: :username_ap_id) }
146+
147+
it 'returns a string starting with web domain and with the expected path' do
148+
expect(subject.uri_for(status))
149+
.to eq("#{host_prefix}/users/#{status.account.username}/statuses/#{status.id}/activity")
150+
end
151+
end
152+
end
131153
end
132154

133155
context 'with a remote status' do

0 commit comments

Comments
 (0)