Skip to content

Commit

Permalink
Fix replies collection incorrectly looping (mastodon#17462)
Browse files Browse the repository at this point in the history
* Refactor tests

* Add tests

* Fix replies collection incorrectly looping
  • Loading branch information
ClearlyClaire authored Feb 7, 2022
1 parent 0d2cf3c commit 73a7823
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 173 deletions.
32 changes: 23 additions & 9 deletions app/controllers/activitypub/replies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,29 @@ def only_other_accounts?
end

def next_page
only_other_accounts = !(@replies&.last&.account_id == @account.id && @replies.size == DESCENDANTS_LIMIT)

account_status_replies_url(
@account,
@status,
page: true,
min_id: only_other_accounts && !only_other_accounts? ? nil : @replies&.last&.id,
only_other_accounts: only_other_accounts
)
if only_other_accounts?
# Only consider remote accounts
return nil if @replies.size < DESCENDANTS_LIMIT

account_status_replies_url(
@account,
@status,
page: true,
min_id: @replies&.last&.id,
only_other_accounts: true
)
else
# For now, we're serving only self-replies, but next page might be other accounts
next_only_other_accounts = @replies&.last&.account_id != @account.id || @replies.size < DESCENDANTS_LIMIT

account_status_replies_url(
@account,
@status,
page: true,
min_id: next_only_other_accounts ? nil : @replies&.last&.id,
only_other_accounts: next_only_other_accounts
)
end
end

def page_params
Expand Down
Loading

0 comments on commit 73a7823

Please sign in to comment.