Skip to content
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

Blank out extra info for deleted or removed content. Fixes #1679 #1680

Merged
merged 1 commit into from
Jul 30, 2021

Conversation

dessalines
Copy link
Member

@dessalines dessalines commented Jul 30, 2021

I don't particularly like this solution, as this blanking happens after the database calls, so requires some in-code manipulation, when I'd really rather have the DB be able to do it. But there's no way that I can think of to do that, IE blanking other columns if one is a certain result.

The vector looping if probably fast enough that it's not an issue.

@dessalines dessalines requested a review from Nutomic July 30, 2021 18:18
Comment on lines +263 to +276
impl DeleteableOrRemoveable for Post {
fn blank_out_deleted_or_removed_info(mut self) -> Self {
self.name = "".into();
self.url = None;
self.body = None;
self.embed_title = None;
self.embed_description = None;
self.embed_html = None;
self.thumbnail_url = None;

self
}
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main thing, adding a trait for these types that allows you to blank out some fields.

Comment on lines +158 to +165
// Blank out deleted or removed info
for pv in posts
.iter_mut()
.filter(|p| p.post.deleted || p.post.removed)
{
pv.post = pv.to_owned().post.blank_out_deleted_or_removed_info();
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vector versions of these are a bit verbose, but I can't think of a good way to do them without using maybe another trait with an associated type.

@Nutomic
Copy link
Member

Nutomic commented Jul 30, 2021

Its certainly not the most elegant solution, and its easy to forget the blank_out call somewhere. I guess we could make these fields optional, or make a separate struct for DeletedComment or something like that. But its good enough for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants