diff --git a/app/rest/admin.go b/app/rest/admin.go index 11627d41..e24a0c34 100644 --- a/app/rest/admin.go +++ b/app/rest/admin.go @@ -120,11 +120,8 @@ func (a *admin) maskBlockedUsers(comments []store.Comment) (res []store.Comment) res = make([]store.Comment, len(comments)) for i, c := range comments { if a.dataService.IsBlocked(c.Locator.SiteID, c.User.ID) { + c = store.MaskComment(c) c.User.Blocked = true - c.Text = "this comment was deleted" - c.Score = 0 - c.Votes = map[string]bool{} - c.Edit = nil } res[i] = c } diff --git a/app/store/bolt.go b/app/store/bolt.go index 71181361..770f8754 100644 --- a/app/store/bolt.go +++ b/app/store/bolt.go @@ -142,11 +142,8 @@ func (b *BoltDB) Delete(locator Locator, commentID string) error { return errors.Wrapf(err, "can't load key %s from bucket %s", commentID, locator.URL) } // set deleted status and clear fields + comment = MaskComment(comment) comment.Deleted = true - comment.Text = "this comment was deleted" - comment.Score = 0 - comment.Votes = map[string]bool{} - comment.Edit = nil if err := b.save(bucket, []byte(commentID), comment); err != nil { return errors.Wrapf(err, "can't save deleted comment for key %s from bucket %s", commentID, locator.URL) diff --git a/app/store/store.go b/app/store/store.go index d58adff3..558423af 100644 --- a/app/store/store.go +++ b/app/store/store.go @@ -133,3 +133,12 @@ func sortComments(comments []Comment, sortFld string) []Comment { }) return comments } + +// MaskComment clears comment info, reset to "Deleted/Blocked" +func MaskComment(comment Comment) Comment { + comment.Text = "this comment was deleted" + comment.Score = 0 + comment.Votes = map[string]bool{} + comment.Edit = nil + return comment +}