fix(backend): hide deleted users from listings - #521
Open
luizhcastro wants to merge 1 commit into
Open
luizhcastro wants to merge 1 commit into
luizhcastro wants to merge 1 commit into
Conversation
Account deletion is a soft delete that rewrites the username to deleted_<uuid>, but every listing query joined users without filtering deletedAt, leaking the anonymized handle into reviews, replies, likes, followers, recommendations, lists and the activity feed. Turn those joins into inner joins filtered by deletedAt so rows owned by deleted users are dropped. In the activity feed this also covers FOLLOW_USER activities whose target was deleted. Closes plotwist-app#520
|
@luizhcastro is attempting to deploy a commit to the status-451 Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
Account deletion is a soft delete:
deleteUsersetsdeletedAtand rewrites the username todeleted_<uuid>, keeping the row. Every listing query still joineduserswithout filteringdeletedAt, so the anonymized handle leaked into the UI — e.g. a review signeddeleted_b8ac47655ca344abaa16debbcd959200on https://plotwist.app/en-US/movies/157336.This turns those
leftJoin(users)intoinnerJoinfiltered byisNull(users.deletedAt), so rows owned by a deleted user are dropped from the listing:reviews-repository.tsreview-replies-repository.tslikes-repository.tsfollowers-repository.tsrecommendations-repository.tslist-repository.tsuser-activities.tsFOLLOW_USERtarget)Backend only — no API contract change, so web and iOS are both covered without client work.
How it was verified
get-reviews.spec.ts(testcontainers, real Postgres): fails onmain, passes with the fix.DELETE /user) → before the fixGET /reviewsreturnsdeleted_bcd680b5b76e4baabd62f087b4a170e8, after the fix only the active user's review is listed. Same check done forGET /review-replies. Review rows stay in the database — this only hides them.Note for reviewers: #520 lists three other approaches (generic "Deleted user" label, hard delete, mixed). This PR implements the "hide" option since it needs no client or i18n work; happy to switch if you prefer another. Not covered here:
likeCount/replyCountstill count interactions made by deleted users, and the nestedauthorsubqueries inbuildReviewInfo/buildReplyInfo.Issue ticket number and link
Closes #520 — #520
Checklist before requesting a review
deleted_<id>across the app.