only permanent blocking delete all comments

This commit is contained in:
Umputun
2019-06-28 11:58:09 -05:00
parent c09eaa6e00
commit 60d9f207ae
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -145,8 +145,8 @@ func (a *admin) setBlockCtrl(w http.ResponseWriter, r *http.Request) {
return
}
// delete comments for blocked user.
if blockStatus {
// delete comments for permanently blocked user.
if blockStatus && ttl == time.Duration(0) {
if err := a.dataService.DeleteUser(siteID, userID, store.SoftDelete); err != nil {
log.Printf("[WARN] can't delete comments for blocked user %s on site %s, %v", userID, siteID, err)
}
+2 -2
View File
@@ -348,8 +348,8 @@ func TestAdmin_Block(t *testing.T) {
err = json.Unmarshal([]byte(res), &comments)
assert.Nil(t, err)
assert.Equal(t, 4, len(comments.Comments), "should have 4 comments")
assert.Equal(t, "", comments.Comments[0].Text, "still deleted")
assert.True(t, comments.Comments[0].Deleted)
assert.Equal(t, "test test #1", comments.Comments[2].Text, "restored")
assert.False(t, comments.Comments[2].Deleted)
assert.False(t, srv.adminRest.dataService.IsBlocked("radio-t", "user1"))
assert.False(t, srv.adminRest.dataService.IsBlocked("radio-t", "user2"))