From 60d9f207ae575165a792c3b7dbfea9ae2fc80a89 Mon Sep 17 00:00:00 2001 From: Umputun Date: Fri, 28 Jun 2019 11:58:09 -0500 Subject: [PATCH] only permanent blocking delete all comments --- backend/app/rest/api/admin.go | 4 ++-- backend/app/rest/api/admin_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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"))