diff --git a/backend/app/migrator/disqus.go b/backend/app/migrator/disqus.go index f2f6faba..7da2e6c8 100644 --- a/backend/app/migrator/disqus.go +++ b/backend/app/migrator/disqus.go @@ -137,7 +137,7 @@ func (d *Disqus) convert(r io.Reader, siteID string) (ch chan store.Comment) { ParentID: comment.Pid.Val, Imported: true, } - if c.User.ID == "disqus_" { // empty comment.AuthorUserName from disqus + if comment.AuthorUserName == "" { // empty comment.AuthorUserName from disqus c.User.ID = "disqus_" + c.User.Name } if c.ID == "" { // no comment.UID diff --git a/backend/app/migrator/disqus_test.go b/backend/app/migrator/disqus_test.go index 47030848..cd8dbdab 100644 --- a/backend/app/migrator/disqus_test.go +++ b/backend/app/migrator/disqus_test.go @@ -41,6 +41,10 @@ func TestDisqus_Import(t *testing.T) { assert.Equal(t, "2ba6b71dbf9750ae3356cce14cac6c1b1962747c", c.User.IP) assert.True(t, c.Imported) + c = last[1] // get comment with empty username + assert.Equal(t, "No Username", c.User.Name) + assert.Equal(t, "disqus_No Username", c.User.ID) + posts, err := dataStore.List("test", 0, 0) assert.NoError(t, err) assert.Equal(t, 2, len(posts), "2 posts") @@ -171,10 +175,9 @@ var xmlTestDisqus = ` false false - dmitri.noname@gmail.com - Dmitry Noname + john.nousername@gmail.com + No Username false - google-74b9e7568ef6860e93862c5d77590123 89.89.89.139 diff --git a/backend/app/store/user.go b/backend/app/store/user.go index 9d8b28ad..6b109a28 100644 --- a/backend/app/store/user.go +++ b/backend/app/store/user.go @@ -50,7 +50,7 @@ func EncodeID(id string) string { func hashWithFallback(h hash.Hash, val string) string { if reValidSha.MatchString(val) { - return val // already hashed or empty + return val // already hashed } if _, err := io.WriteString(h, val); err != nil {