Skip to content

Commit 2c35bef

Browse files
ClearlyClairehiyuki2578
authored andcommitted
Fix multiple issues with replies collection for pages further than self-replies (mastodon#11582)
* Fix the replies collection returning snowflakes ids rather than URIs Fixes mastodon#11568 * Fix min_id in replies queries once self-replies are exhausted * Fix `next` attribute of replies collection being nil when there are no self-replies * Rename other_accounts param to only_other_accounts
1 parent da6a43f commit 2c35bef

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

app/controllers/activitypub/replies_controller.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def set_status
2727
end
2828

2929
def set_replies
30-
@replies = page_params[:other_accounts] ? Status.where.not(account_id: @account.id) : @account.statuses
30+
@replies = page_params[:only_other_accounts] ? Status.where.not(account_id: @account.id) : @account.statuses
3131
@replies = @replies.where(in_reply_to_id: @status.id, visibility: [:public, :unlisted])
3232
@replies = @replies.paginate_by_min_id(DESCENDANTS_LIMIT, params[:min_id])
3333
end
@@ -38,7 +38,7 @@ def replies_collection_presenter
3838
type: :unordered,
3939
part_of: account_status_replies_url(@account, @status),
4040
next: next_page,
41-
items: @replies.map { |status| status.local ? status : status.id }
41+
items: @replies.map { |status| status.local ? status : status.uri }
4242
)
4343

4444
return page if page_requested?
@@ -55,16 +55,17 @@ def page_requested?
5555
end
5656

5757
def next_page
58+
only_other_accounts = !(@replies&.last&.account_id == @account.id && @replies.size == DESCENDANTS_LIMIT)
5859
account_status_replies_url(
5960
@account,
6061
@status,
6162
page: true,
62-
min_id: @replies&.last&.id,
63-
other_accounts: !(@replies&.last&.account_id == @account.id && @replies.size == DESCENDANTS_LIMIT)
63+
min_id: only_other_accounts && !page_params[:only_other_accounts] ? nil : @replies&.last&.id,
64+
only_other_accounts: only_other_accounts
6465
)
6566
end
6667

6768
def page_params
68-
params_slice(:other_accounts, :min_id).merge(page: true)
69+
params_slice(:only_other_accounts, :min_id).merge(page: true)
6970
end
7071
end

app/serializers/activitypub/note_serializer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def replies
5555
type: :unordered,
5656
part_of: ActivityPub::TagManager.instance.replies_uri_for(object),
5757
items: replies.map(&:second),
58-
next: last_id ? ActivityPub::TagManager.instance.replies_uri_for(object, page: true, min_id: last_id) : nil
58+
next: last_id ? ActivityPub::TagManager.instance.replies_uri_for(object, page: true, min_id: last_id) : ActivityPub::TagManager.instance.replies_uri_for(object, page: true, only_other_accounts: true)
5959
)
6060
)
6161
end

0 commit comments

Comments
 (0)