[1.0] Pagination for VoteView is broken
It stores only PersonId in the cursor but then tries to get both PersonId and PostId out of it. That is impossible.
- https://github.com/LemmyNet/lemmy/blob/2e6045143e4959858ac1a6006136e3fbb56ea199/crates/db_views/vote/src/impls.rs#L32
- https://github.com/LemmyNet/lemmy/blob/2e6045143e4959858ac1a6006136e3fbb56ea199/crates/db_views/vote/src/impls.rs#L42
As part of #6159 I tried to fix in the same way to cursors for SearchCombinedView are handled. But that also doesnt work, because CursorData must be the same type which is used as key for .then_order_by() (here SearchCombined). For VoteView this doesnt work because there is no table VoteCombined.
So Im disabling the broken pagination code for now until we can find a solution. Still Im keeping the api structs with pagination cursors so this can be fixed without a breaking change.
Edit: The best solution is probably to have two separate structs VoteViewPost and VoteViewComment, each handling pagination separately. These can be converted to a single VoteView for the api.
Edit: The best solution is probably to have two separate structs VoteViewPost and VoteViewComment, each handling pagination separately. These can be converted to a single VoteView for the api.
That's fine, and its not even really needed that you map them to a unified VoteView, just keep VoteViewPost and VoteViewComment separate (they're never combined anyway). And you can probably just use the person.id as the cursor... not sure why the person_id and post_id would be necessary anyway, these are only for looking at one post / comment.
The cursor needs to point to a specific row on that table, if you only have person_id it would return many different rows.
By the way it would make sense to move the list like endpoints to an unstable api path (https://github.com/LemmyNet/lemmy/issues/5945) so that we can make breaking changes without delaying the 1.0 release. The existing simple listing of votes on a post isnt that helpful, and it would be good to implement something like https://github.com/LemmyNet/lemmy/pull/5669 after 1.0 without requiring a new major version.
The cursor needs to point to a specific row on that table, if you only have person_id it would return many different rows.
Ah yeah you're right, since its using the _actions table, so it needs the content id also.
I'd rather have this fixed for 1.0, its been working already in v0.19 for a long time (in both lemmy-ui and jerboa), and its been extremely useful for finding no content vote accounts, which are one of the biggest attack vectors on lemmy rn, and have been for a long time.