-
-
Notifications
You must be signed in to change notification settings - Fork 859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle displaying of deleted and removed posts/comments (fixes #2624) #3286
Conversation
69a1ad0
to
dde98f5
Compare
query = query | ||
.filter(community::removed.eq(false)) | ||
.filter(post::removed.eq(false)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its a bit unclear what to do if the community was removed/deleted, we can revisit this if issues are reported in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difficulty with this one, and why this really needs a SQL solution (that's better than my old one), is that the posts fetched are a collection of posts that might be yours + others.
With admins and mods, we can just show all deleted and removed. When its the creator, we need to do a join + filter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the current usage this is no problem as show_removed and show_deleted are only set on the user profile, so it will only include posts authored by that user. But if it ever gets set from somewhere else that will cause problems. As an admin I also dont want to see deleted and removed posts all over the frontpage, its pretty annoying.
As a kind of solution/workaround we could add a check that show_removed/show_deleted can only be true if creator_id is Some?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a kind of solution/workaround we could add a check that show_removed/show_deleted can only be true if creator_id is Some?
That creator_id filter is only called from the profile pages, so that means /home and /community would show deleted posts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because !self.show_removed.unwrap_or(false)
with show_removed = None
evaluates to !false
which is true so the code in if is executed. Admittedly its confusing but its also covered by tests.
I changed the code now to avoid explicit show_removed/show_deleted parameters. If this looks better to you, I will also fix the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does look better.
dde98f5
to
05830f5
Compare
b3241cf
to
15f3449
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you get the tests passing, feel free to merge.
query = query | ||
.filter(community::removed.eq(false)) | ||
.filter(post::removed.eq(false)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does look better.
|
Clippy failing. |
Edit: actually not, because this PR doesnt change PostView::read. So this is ready to merge |
Added another change to allow returning own deleted posts from PostView::read, which makes #3613 obsolete. I tested to confirm that its working for unauthenticated users. |
Forgot to remove this in #3286
Makes it so that deleted and removed posts/comments are only shown on the creator's profile page in the following cases:
The existing code would also show deleted/removed posts and comments to admins/mods in post listings and search results, I dont think thats desirable.