diff --git a/pkg/files/files.go b/pkg/files/files.go index beb8da8ab..08beb9771 100644 --- a/pkg/files/files.go +++ b/pkg/files/files.go @@ -21,6 +21,7 @@ import ( "os" "strconv" "time" + "xorm.io/xorm" "code.vikunja.io/api/pkg/config" diff --git a/pkg/models/export.go b/pkg/models/export.go index dd3686975..2b600c37f 100644 --- a/pkg/models/export.go +++ b/pkg/models/export.go @@ -1,24 +1,30 @@ -// Copyright 2021 Vikunja and contriubtors. All rights reserved. +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-2021 Vikunja and contributors. All rights reserved. // -// This file is part of Vikunja. -// -// Vikunja is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public Licensee as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // -// Vikunja is distributed in the hope that it will be useful, +// This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. +// GNU Affero General Public Licensee for more details. // -// You should have received a copy of the GNU General Public License -// along with Vikunja. If not, see . +// You should have received a copy of the GNU Affero General Public Licensee +// along with this program. If not, see . package models import ( "archive/zip" + "encoding/json" + "fmt" + "io" + "os" + "strconv" + "time" + "code.vikunja.io/api/pkg/config" "code.vikunja.io/api/pkg/cron" "code.vikunja.io/api/pkg/db" @@ -28,12 +34,6 @@ import ( "code.vikunja.io/api/pkg/user" "code.vikunja.io/api/pkg/utils" "code.vikunja.io/api/pkg/version" - "encoding/json" - "fmt" - "io" - "os" - "strconv" - "time" "xorm.io/xorm" ) diff --git a/pkg/modules/dump/dump.go b/pkg/modules/dump/dump.go index f0aa718ec..48f85256a 100644 --- a/pkg/modules/dump/dump.go +++ b/pkg/modules/dump/dump.go @@ -18,15 +18,16 @@ package dump import ( "archive/zip" + "fmt" + "io" + "os" + "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/files" "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/utils" "code.vikunja.io/api/pkg/version" - "fmt" "github.com/spf13/viper" - "io" - "os" ) // Dump creates a zip file with all vikunja files at filename diff --git a/pkg/modules/migration/handler/common.go b/pkg/modules/migration/handler/common.go index 358f3dca0..2dfe04442 100644 --- a/pkg/modules/migration/handler/common.go +++ b/pkg/modules/migration/handler/common.go @@ -17,11 +17,12 @@ package handler import ( + "net/http" + "code.vikunja.io/api/pkg/modules/migration" user2 "code.vikunja.io/api/pkg/user" "code.vikunja.io/web/handler" "github.com/labstack/echo/v4" - "net/http" ) func status(ms migration.MigratorName, c echo.Context) error { diff --git a/pkg/modules/migration/handler/handler_file.go b/pkg/modules/migration/handler/handler_file.go index 0b3fc4f49..427c0ba57 100644 --- a/pkg/modules/migration/handler/handler_file.go +++ b/pkg/modules/migration/handler/handler_file.go @@ -17,12 +17,13 @@ package handler import ( + "net/http" + "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/modules/migration" user2 "code.vikunja.io/api/pkg/user" "code.vikunja.io/web/handler" "github.com/labstack/echo/v4" - "net/http" ) type FileMigratorWeb struct { diff --git a/pkg/modules/migration/vikunja-file/main_test.go b/pkg/modules/migration/vikunja-file/main_test.go index bd5e11348..d618888df 100644 --- a/pkg/modules/migration/vikunja-file/main_test.go +++ b/pkg/modules/migration/vikunja-file/main_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public Licensee // along with this program. If not, see . -package vikunja_file +package vikunjafile import ( "os" diff --git a/pkg/modules/migration/vikunja-file/vikunja.go b/pkg/modules/migration/vikunja-file/vikunja.go index d410d467e..dfd6be277 100644 --- a/pkg/modules/migration/vikunja-file/vikunja.go +++ b/pkg/modules/migration/vikunja-file/vikunja.go @@ -14,33 +14,34 @@ // You should have received a copy of the GNU Affero General Public Licensee // along with this program. If not, see . -package vikunja_file +package vikunjafile import ( "archive/zip" "bytes" - "code.vikunja.io/api/pkg/db" - "code.vikunja.io/api/pkg/log" - "code.vikunja.io/api/pkg/models" - "code.vikunja.io/api/pkg/modules/migration" - "code.vikunja.io/api/pkg/user" "encoding/json" "fmt" "io" "strconv" "strings" + + "code.vikunja.io/api/pkg/db" + "code.vikunja.io/api/pkg/log" + "code.vikunja.io/api/pkg/models" + "code.vikunja.io/api/pkg/modules/migration" + "code.vikunja.io/api/pkg/user" ) const logPrefix = "[Vikunja File Import] " -type VikunjaFileMigrator struct { +type FileMigrator struct { } -func (v *VikunjaFileMigrator) Name() string { +func (v *FileMigrator) Name() string { return "vikunja-file" } -func (v *VikunjaFileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) error { +func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) error { r, err := zip.NewReader(file, size) if err != nil { return fmt.Errorf("could not open import file: %s", err) diff --git a/pkg/modules/migration/vikunja-file/vikunja_test.go b/pkg/modules/migration/vikunja-file/vikunja_test.go index 998646520..5d5361a4d 100644 --- a/pkg/modules/migration/vikunja-file/vikunja_test.go +++ b/pkg/modules/migration/vikunja-file/vikunja_test.go @@ -14,21 +14,22 @@ // You should have received a copy of the GNU Affero General Public Licensee // along with this program. If not, see . -package vikunja_file +package vikunjafile import ( + "os" + "testing" + "code.vikunja.io/api/pkg/config" "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/user" "github.com/stretchr/testify/assert" - "os" - "testing" ) func TestVikunjaFileMigrator_Migrate(t *testing.T) { db.LoadAndAssertFixtures(t) - m := &VikunjaFileMigrator{} + m := &FileMigrator{} u := &user.User{ID: 1} f, err := os.Open(config.ServiceRootpath.GetString() + "/pkg/modules/migration/vikunja-file/export.zip") diff --git a/pkg/routes/api/v1/info.go b/pkg/routes/api/v1/info.go index c2c99b307..74afd75bb 100644 --- a/pkg/routes/api/v1/info.go +++ b/pkg/routes/api/v1/info.go @@ -17,9 +17,10 @@ package v1 import ( - vikunja_file "code.vikunja.io/api/pkg/modules/migration/vikunja-file" "net/http" + vikunja_file "code.vikunja.io/api/pkg/modules/migration/vikunja-file" + microsofttodo "code.vikunja.io/api/pkg/modules/migration/microsoft-todo" "code.vikunja.io/api/pkg/modules/migration/trello" @@ -93,7 +94,7 @@ func Info(c echo.Context) error { EmailRemindersEnabled: config.ServiceEnableEmailReminders.GetBool(), UserDeletionEnabled: config.ServiceEnableUserDeletion.GetBool(), AvailableMigrators: []string{ - (&vikunja_file.VikunjaFileMigrator{}).Name(), + (&vikunja_file.FileMigrator{}).Name(), }, Legal: legalInfo{ ImprintURL: config.LegalImprintURL.GetString(), diff --git a/pkg/routes/api/v1/user_export.go b/pkg/routes/api/v1/user_export.go index edfebbad0..c731d0cf3 100644 --- a/pkg/routes/api/v1/user_export.go +++ b/pkg/routes/api/v1/user_export.go @@ -17,6 +17,8 @@ package v1 import ( + "net/http" + "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/events" "code.vikunja.io/api/pkg/files" @@ -24,7 +26,6 @@ import ( "code.vikunja.io/api/pkg/user" "code.vikunja.io/web/handler" "github.com/labstack/echo/v4" - "net/http" "xorm.io/xorm" ) diff --git a/pkg/routes/routes.go b/pkg/routes/routes.go index faf2fd00f..b340aa6da 100644 --- a/pkg/routes/routes.go +++ b/pkg/routes/routes.go @@ -47,12 +47,13 @@ package routes import ( - vikunja_file "code.vikunja.io/api/pkg/modules/migration/vikunja-file" "errors" "fmt" "strings" "time" + vikunja_file "code.vikunja.io/api/pkg/modules/migration/vikunja-file" + "code.vikunja.io/api/pkg/config" "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/log" @@ -637,7 +638,7 @@ func registerMigrations(m *echo.Group) { vikunjaFileMigrationHandler := &migrationHandler.FileMigratorWeb{ MigrationStruct: func() migration.FileMigrator { - return &vikunja_file.VikunjaFileMigrator{} + return &vikunja_file.FileMigrator{} }, } vikunjaFileMigrationHandler.RegisterRoutes(m)