From 885b4c6689623f099601ec7f5190cc9b70fadc6f Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Tue, 31 Mar 2020 06:03:26 -0400 Subject: [PATCH] api: use commentoExportV1 struct --- api/domain_export.go | 8 +------- api/domain_import_commento.go | 4 ++-- api/domain_import_commento_test.go | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/api/domain_export.go b/api/domain_export.go index 9aa2708..1c99bd6 100644 --- a/api/domain_export.go +++ b/api/domain_export.go @@ -15,13 +15,7 @@ func domainExportBeginError(email string, toName string, domain string, err erro } func domainExportBegin(email string, toName string, domain string) { - type dataExport struct { - Version int `json:"version"` - Comments []comment `json:"comments"` - Commenters []commenter `json:"commenters"` - } - - e := dataExport{Version: 1, Comments: []comment{}, Commenters: []commenter{}} + e := commentoExportV1{Version: 1, Comments: []comment{}, Commenters: []commenter{}} statement := ` SELECT commentHex, domain, path, commenterHex, markdown, parentHex, score, state, creationDate diff --git a/api/domain_import_commento.go b/api/domain_import_commento.go index a09da73..52cbdb1 100644 --- a/api/domain_import_commento.go +++ b/api/domain_import_commento.go @@ -8,7 +8,7 @@ import ( "net/http" ) -type dataImport struct { +type commentoExportV1 struct { Version int `json:"version"` Comments []comment `json:"comments"` Commenters []commenter `json:"commenters"` @@ -44,7 +44,7 @@ func domainImportCommento(domain string, url string) (int, error) { return 0, errorInternal } - var data dataImport + var data commentoExportV1 if err := json.Unmarshal(contents, &data); err != nil { logger.Errorf("cannot unmarshal JSON at %s: %v", url, err) return 0, errorInternal diff --git a/api/domain_import_commento_test.go b/api/domain_import_commento_test.go index 9f31690..84cf612 100644 --- a/api/domain_import_commento_test.go +++ b/api/domain_import_commento_test.go @@ -14,7 +14,7 @@ func TestImportCommento(t *testing.T) { failTestOnError(t, setupTestEnv()) // Create JSON data - data := dataImport{ + data := commentoExportV1{ Version: 1, Comments: []comment{ {