Fix for marking a comment as read.

This commit is contained in:
Dessalines 2019-04-25 08:33:25 -07:00
parent 3b181d027c
commit 3b75230654

View File

@ -1311,6 +1311,10 @@ impl Perform for EditComment {
let user_id = claims.id; let user_id = claims.id;
// You are allowed to mark the comment as read even if you're banned.
if self.read.is_none() {
// Verify its the creator or a mod, or an admin // Verify its the creator or a mod, or an admin
let orig_comment = CommentView::read(&conn, self.edit_id, None)?; let orig_comment = CommentView::read(&conn, self.edit_id, None)?;
let mut editors: Vec<i32> = vec![self.creator_id]; let mut editors: Vec<i32> = vec![self.creator_id];
@ -1333,8 +1337,6 @@ impl Perform for EditComment {
return Err(self.error("Not allowed to edit comment."))? return Err(self.error("Not allowed to edit comment."))?
} }
// You are allowed to mark the comment as read even if you're banned.
if self.read.is_none() {
// Check for a community ban // Check for a community ban
if CommunityUserBanView::get(&conn, user_id, orig_comment.community_id).is_ok() { if CommunityUserBanView::get(&conn, user_id, orig_comment.community_id).is_ok() {
return Err(self.error("You have been banned from this community"))? return Err(self.error("You have been banned from this community"))?
@ -1344,6 +1346,7 @@ impl Perform for EditComment {
if UserView::read(&conn, user_id)?.banned { if UserView::read(&conn, user_id)?.banned {
return Err(self.error("You have been banned from the site"))? return Err(self.error("You have been banned from the site"))?
} }
} }
let content_slurs_removed = remove_slurs(&self.content.to_owned()); let content_slurs_removed = remove_slurs(&self.content.to_owned());