From 91441d11603e92d7286e4305fda0873a5eee6b9f Mon Sep 17 00:00:00 2001 From: Umputun Date: Wed, 1 Sep 2021 14:21:52 -0500 Subject: [PATCH] add controversy and imported to untrusted list --- backend/app/store/comment.go | 2 ++ backend/app/store/comment_test.go | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/backend/app/store/comment.go b/backend/app/store/comment.go index e12c2ab1..0c52a96f 100644 --- a/backend/app/store/comment.go +++ b/backend/app/store/comment.go @@ -86,9 +86,11 @@ func (c *Comment) PrepareUntrusted() { c.Votes = make(map[string]bool) c.VotedIPs = make(map[string]VotedIPInfo) c.Score = 0 + c.Controversy = 0 c.Edit = nil c.Pin = false c.Deleted = false + c.Imported = false } // SetDeleted clears comment info, reset to deleted state. hard flag will clear all user info as well diff --git a/backend/app/store/comment_test.go b/backend/app/store/comment_test.go index ebe8ab7f..836e097a 100644 --- a/backend/app/store/comment_test.go +++ b/backend/app/store/comment_test.go @@ -87,16 +87,18 @@ func TestComment_Sanitize(t *testing.T) { func TestComment_PrepareUntrusted(t *testing.T) { comment := Comment{ - Text: `blah`, - User: User{ID: "username"}, - ParentID: "p123", - ID: "123", - Locator: Locator{SiteID: "site", URL: "url"}, - Score: 10, - Pin: true, - Deleted: true, - Timestamp: time.Date(2018, 1, 1, 9, 30, 0, 0, time.Local), - Votes: map[string]bool{"uu": true}, + Text: `blah`, + User: User{ID: "username"}, + ParentID: "p123", + ID: "123", + Locator: Locator{SiteID: "site", URL: "url"}, + Score: 10, + Pin: true, + Deleted: true, + Timestamp: time.Date(2018, 1, 1, 9, 30, 0, 0, time.Local), + Votes: map[string]bool{"uu": true}, + Controversy: 123, + Imported: true, } comment.PrepareUntrusted() @@ -110,6 +112,8 @@ func TestComment_PrepareUntrusted(t *testing.T) { assert.Equal(t, make(map[string]bool), comment.Votes) assert.Equal(t, make(map[string]VotedIPInfo), comment.VotedIPs) assert.Equal(t, User{ID: "username"}, comment.User) + assert.Equal(t, 0., comment.Controversy) + assert.Equal(t, false, comment.Imported) }