diff --git a/backend/app/rest/api/admin.go b/backend/app/rest/api/admin.go index 39057c1d..cc0e6410 100644 --- a/backend/app/rest/api/admin.go +++ b/backend/app/rest/api/admin.go @@ -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) } diff --git a/backend/app/rest/api/admin_test.go b/backend/app/rest/api/admin_test.go index 9d7ee71c..6398cc24 100644 --- a/backend/app/rest/api/admin_test.go +++ b/backend/app/rest/api/admin_test.go @@ -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"))