From 769db0dab2e50bc477dec6c7e18309effc80a1bd Mon Sep 17 00:00:00 2001 From: renovate Date: Thu, 16 Mar 2023 00:01:43 +0000 Subject: [PATCH 01/16] fix(deps): update module github.com/imdario/mergo to v0.3.14 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index c8d87f55b..2d20bf81c 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 github.com/google/uuid v1.3.0 github.com/iancoleman/strcase v0.2.0 - github.com/imdario/mergo v0.3.13 + github.com/imdario/mergo v0.3.14 github.com/jinzhu/copier v0.3.5 github.com/labstack/echo-jwt/v4 v4.1.0 github.com/labstack/echo/v4 v4.10.2 diff --git a/go.sum b/go.sum index 51b3f9c30..7859143c7 100644 --- a/go.sum +++ b/go.sum @@ -348,6 +348,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= +github.com/imdario/mergo v0.3.14 h1:fOqeC1+nCuuk6PKQdg9YmosXX7Y7mHX6R/0ZldI9iHo= +github.com/imdario/mergo v0.3.14/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= From 8916de03666482c2319689e950d30a6fb737f239 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 16 Mar 2023 19:08:18 +0100 Subject: [PATCH 02/16] fix: update redoc --- pkg/routes/api/v1/docs.go | 1909 +++++++++++++++++++++++++++++++++++-- 1 file changed, 1804 insertions(+), 105 deletions(-) diff --git a/pkg/routes/api/v1/docs.go b/pkg/routes/api/v1/docs.go index 26c404557..d05bf951c 100644 --- a/pkg/routes/api/v1/docs.go +++ b/pkg/routes/api/v1/docs.go @@ -61,119 +61,1818 @@ const RedocUITemplate = ` ` From a0b3a444df5e23a88d47972a8034a2dfe912f02f Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 18 Mar 2023 09:55:18 +0100 Subject: [PATCH 03/16] fix(lint): disable misspell linter on redoc --- .golangci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci.yml b/.golangci.yml index 22a7ea6b1..36ce6ef4b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -79,6 +79,7 @@ issues: - path: pkg/routes/api/v1/docs.go linters: - goheader + - misspell - text: "Missed string" linters: - goheader From 085b9222bbe631c31d5fea9568b7997f88d16094 Mon Sep 17 00:00:00 2001 From: renovate Date: Sat, 18 Mar 2023 09:01:35 +0000 Subject: [PATCH 04/16] fix(deps): update github.com/arran4/golang-ical digest to 19abf92 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2d20bf81c..40ee46e1c 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( gitea.com/xorm/xorm-redis-cache v0.2.0 github.com/ThreeDotsLabs/watermill v1.2.0 github.com/adlio/trello v1.10.0 - github.com/arran4/golang-ical v0.0.0-20230213232137-07c6aad5e4f0 + github.com/arran4/golang-ical v0.0.0-20230318005454-19abf92700cc github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef github.com/bbrks/go-blurhash v1.1.1 github.com/c2h5oh/datasize v0.0.0-20220606134207-859f65c6625b diff --git a/go.sum b/go.sum index 7859143c7..b83ed67f7 100644 --- a/go.sum +++ b/go.sum @@ -78,6 +78,8 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/arran4/golang-ical v0.0.0-20230213232137-07c6aad5e4f0 h1:VVPogIxPiZ6WK5G4Pve5VSQ4HEFiJ8GChpqRjo1gN2c= github.com/arran4/golang-ical v0.0.0-20230213232137-07c6aad5e4f0/go.mod h1:BSTTrYHuM12oAL8jDdcmPdw02SBThKYWNFHQlvEG6b0= +github.com/arran4/golang-ical v0.0.0-20230318005454-19abf92700cc h1:up1aDcTCZ3KrL2ukKxNqjMRx/CCaXyn9Wl6N7ea3EWc= +github.com/arran4/golang-ical v0.0.0-20230318005454-19abf92700cc/go.mod h1:BSTTrYHuM12oAL8jDdcmPdw02SBThKYWNFHQlvEG6b0= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= From 6d8db0ce1e00e8c200a43b28ac98eb0fb825f4d4 Mon Sep 17 00:00:00 2001 From: renovate Date: Mon, 20 Mar 2023 20:21:40 +0000 Subject: [PATCH 05/16] chore(deps): update goreleaser/nfpm docker tag to v2.27.1 (#1438) Co-authored-by: kolaente Reviewed-on: https://kolaente.dev/vikunja/api/pulls/1438 Co-authored-by: renovate Co-committed-by: renovate --- .drone.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index ed60414b9..b516a40e2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -506,7 +506,7 @@ steps: # Build os packages and push it to our bucket - name: build-os-packages-unstable - image: goreleaser/nfpm:v2.26.0 + image: goreleaser/nfpm:v2.27.1 pull: always commands: - apk add git go @@ -522,7 +522,7 @@ steps: depends_on: [ after-build-compress ] - name: build-os-packages-version - image: goreleaser/nfpm:v2.26.0 + image: goreleaser/nfpm:v2.27.1 pull: always commands: - apk add git go @@ -731,6 +731,6 @@ steps: - failure --- kind: signature -hmac: 7242860ad70556ffeb8fc804ce0ffa0d3d1aa8e0d9167ad476aa392d7e937d48 +hmac: f1743e2bb4ca8e5d8df1e222720feb4eac91e15a5ef74d4b54f1df246f2353fe ... From 6566f0e81dac9e0292444511ab3be92173bd5430 Mon Sep 17 00:00:00 2001 From: renovate Date: Tue, 21 Mar 2023 13:01:35 +0000 Subject: [PATCH 06/16] fix(deps): update module github.com/swaggo/swag to v1.8.11 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 40ee46e1c..ba05f4665 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( github.com/spf13/cobra v1.6.1 github.com/spf13/viper v1.15.0 github.com/stretchr/testify v1.8.2 - github.com/swaggo/swag v1.8.10 + github.com/swaggo/swag v1.8.11 github.com/tkuchiki/go-timezone v0.2.2 github.com/ulule/limiter/v3 v3.11.1 github.com/vectordotdev/go-datemath v0.1.1-0.20220323213446-f3954d0b18ae diff --git a/go.sum b/go.sum index b83ed67f7..9b5fb5d80 100644 --- a/go.sum +++ b/go.sum @@ -688,6 +688,8 @@ github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8 github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/swaggo/swag v1.8.10 h1:eExW4bFa52WOjqRzRD58bgWsWfdFJso50lpbeTcmTfo= github.com/swaggo/swag v1.8.10/go.mod h1:ezQVUUhly8dludpVk+/PuwJWvLLanB13ygV5Pr9enSk= +github.com/swaggo/swag v1.8.11 h1:Fp1dNNtDvbCf+8kvehZbHQnlF6AxHGjmw6H/xAMrZfY= +github.com/swaggo/swag v1.8.11/go.mod h1:2GXgpNI9iy5OdsYWu8zXfRAGnOAPxYxTWTyM0XOTYZQ= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/tkuchiki/go-timezone v0.2.2 h1:MdHR65KwgVTwWFQrota4SKzc4L5EfuH5SdZZGtk/P2Q= From 6aadaaaffc1fff4a94e35e8fa3f6eab397cbc3ce Mon Sep 17 00:00:00 2001 From: WofWca Date: Tue, 21 Mar 2023 13:36:53 +0400 Subject: [PATCH 07/16] chore: rename files (fix typo) --- pkg/models/{prject.go => project.go} | 0 pkg/models/{prject_test.go => project_test.go} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename pkg/models/{prject.go => project.go} (100%) rename pkg/models/{prject_test.go => project_test.go} (100%) diff --git a/pkg/models/prject.go b/pkg/models/project.go similarity index 100% rename from pkg/models/prject.go rename to pkg/models/project.go diff --git a/pkg/models/prject_test.go b/pkg/models/project_test.go similarity index 100% rename from pkg/models/prject_test.go rename to pkg/models/project_test.go From f6e6c5c8fcf834ecafe4475cd932d62028e18441 Mon Sep 17 00:00:00 2001 From: renovate Date: Fri, 24 Mar 2023 10:16:51 +0000 Subject: [PATCH 08/16] fix(deps): update module github.com/imdario/mergo to v0.3.15 (#1443) Reviewed-on: https://kolaente.dev/vikunja/api/pulls/1443 Co-authored-by: renovate Co-committed-by: renovate --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index ba05f4665..0a12018d0 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 github.com/google/uuid v1.3.0 github.com/iancoleman/strcase v0.2.0 - github.com/imdario/mergo v0.3.14 + github.com/imdario/mergo v0.3.15 github.com/jinzhu/copier v0.3.5 github.com/labstack/echo-jwt/v4 v4.1.0 github.com/labstack/echo/v4 v4.10.2 diff --git a/go.sum b/go.sum index 9b5fb5d80..2f6af8fd7 100644 --- a/go.sum +++ b/go.sum @@ -352,6 +352,8 @@ github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/imdario/mergo v0.3.14 h1:fOqeC1+nCuuk6PKQdg9YmosXX7Y7mHX6R/0ZldI9iHo= github.com/imdario/mergo v0.3.14/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= From 4d5ad8f50eb2c540c7bf1dd60a36821855ed1e51 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 24 Mar 2023 19:17:33 +0100 Subject: [PATCH 09/16] chore(deps): update golangci-lint to 1.52.1 --- .drone.yml | 4 ++-- magefile.go | 2 +- pkg/log/noop.go | 2 +- pkg/log/watermill_logger.go | 2 +- pkg/migration/migration.go | 5 +---- pkg/models/kanban.go | 4 ++-- pkg/models/label.go | 4 ++-- pkg/models/label_rights.go | 2 +- pkg/models/label_task.go | 6 +++--- pkg/models/link_sharing.go | 4 ++-- pkg/models/listeners.go | 22 ++++++++++----------- pkg/models/namespace_rights.go | 2 +- pkg/models/namespace_team.go | 4 ++-- pkg/models/namespace_users.go | 4 ++-- pkg/models/notifications_database.go | 4 ++-- pkg/models/project_team.go | 4 ++-- pkg/models/project_users.go | 4 ++-- pkg/models/saved_filters.go | 6 +++--- pkg/models/saved_filters_rights.go | 2 +- pkg/models/task_attachment.go | 4 ++-- pkg/models/task_comments.go | 6 +++--- pkg/models/tasks.go | 2 +- pkg/models/team_members.go | 4 ++-- pkg/models/teams.go | 4 ++-- pkg/models/teams_rights.go | 2 +- pkg/modules/avatar/empty/empty.go | 2 +- pkg/modules/background/unsplash/unsplash.go | 2 +- pkg/modules/background/upload/upload.go | 4 ++-- pkg/routes/caldav/listStorageProvider.go | 6 +++--- pkg/user/listeners.go | 4 ++-- 30 files changed, 62 insertions(+), 65 deletions(-) diff --git a/.drone.yml b/.drone.yml index b516a40e2..876414e2f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -141,7 +141,7 @@ steps: commands: - export "GOROOT=$(go env GOROOT)" - apk --no-cache add build-base git - - wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.2 + - wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.1 - ./mage-static check:all when: event: [ push, tag, pull_request ] @@ -731,6 +731,6 @@ steps: - failure --- kind: signature -hmac: f1743e2bb4ca8e5d8df1e222720feb4eac91e15a5ef74d4b54f1df246f2353fe +hmac: 166caa5ba66cd55bc0f1c5cb42be0a0a647fbadf66716778cf795fc084fc80fd ... diff --git a/magefile.go b/magefile.go index 21dd9cfcd..2e4f49c77 100644 --- a/magefile.go +++ b/magefile.go @@ -405,7 +405,7 @@ func checkGolangCiLintInstalled() { mg.Deps(initVars) if err := exec.Command("golangci-lint").Run(); err != nil && strings.Contains(err.Error(), "executable file not found") { fmt.Println("Please manually install golangci-lint by running") - fmt.Println("curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.2") + fmt.Println("curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.1") os.Exit(1) } } diff --git a/pkg/log/noop.go b/pkg/log/noop.go index 2824c40e6..9075c9e36 100644 --- a/pkg/log/noop.go +++ b/pkg/log/noop.go @@ -23,6 +23,6 @@ import ( // NoopBackend doesn't log anything. Used in cases where we want to disable logging completely. type NoopBackend struct{} -func (n *NoopBackend) Log(level logging.Level, i int, record *logging.Record) error { +func (n *NoopBackend) Log(_ logging.Level, _ int, _ *logging.Record) error { return nil } diff --git a/pkg/log/watermill_logger.go b/pkg/log/watermill_logger.go index 1f49829cd..eae09ae76 100644 --- a/pkg/log/watermill_logger.go +++ b/pkg/log/watermill_logger.go @@ -91,6 +91,6 @@ func (w *WatermillLogger) Trace(msg string, fields watermill.LogFields) { w.logger.Debugf("%s, %s", msg, concatFields(fields)) } -func (w *WatermillLogger) With(fields watermill.LogFields) watermill.LoggerAdapter { +func (w *WatermillLogger) With(_ watermill.LogFields) watermill.LoggerAdapter { return w } diff --git a/pkg/migration/migration.go b/pkg/migration/migration.go index 612042e7c..cbd9ddaa5 100644 --- a/pkg/migration/migration.go +++ b/pkg/migration/migration.go @@ -109,10 +109,7 @@ func Rollback(migrationID string) { // MigrateTo executes all migrations up to a certain point func MigrateTo(migrationID string, x *xorm.Engine) error { m := initMigration(x) - if err := m.MigrateTo(migrationID); err != nil { - return err - } - return nil + return m.MigrateTo(migrationID) } // Deletes a column from a table. All arguments are strings, to let them be standalone and not depending on any struct. diff --git a/pkg/models/kanban.go b/pkg/models/kanban.go index a7f3242f4..01905288d 100644 --- a/pkg/models/kanban.go +++ b/pkg/models/kanban.go @@ -281,7 +281,7 @@ func (b *Bucket) Create(s *xorm.Session, a web.Auth) (err error) { // @Failure 404 {object} web.HTTPError "The bucket does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /projects/{projectID}/buckets/{bucketID} [post] -func (b *Bucket) Update(s *xorm.Session, a web.Auth) (err error) { +func (b *Bucket) Update(s *xorm.Session, _ web.Auth) (err error) { doneBucket, err := getDoneBucketForProject(s, b.ProjectID) if err != nil { return err @@ -320,7 +320,7 @@ func (b *Bucket) Update(s *xorm.Session, a web.Auth) (err error) { // @Failure 404 {object} web.HTTPError "The bucket does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /projects/{projectID}/buckets/{bucketID} [delete] -func (b *Bucket) Delete(s *xorm.Session, a web.Auth) (err error) { +func (b *Bucket) Delete(s *xorm.Session, _ web.Auth) (err error) { // Prevent removing the last bucket total, err := s.Where("project_id = ?", b.ProjectID).Count(&Bucket{}) diff --git a/pkg/models/label.go b/pkg/models/label.go index 5658f1069..5f4bcbd05 100644 --- a/pkg/models/label.go +++ b/pkg/models/label.go @@ -123,7 +123,7 @@ func (l *Label) Update(s *xorm.Session, a web.Auth) (err error) { // @Failure 404 {object} web.HTTPError "Label not found." // @Failure 500 {object} models.Message "Internal error" // @Router /labels/{id} [delete] -func (l *Label) Delete(s *xorm.Session, a web.Auth) (err error) { +func (l *Label) Delete(s *xorm.Session, _ web.Auth) (err error) { _, err = s.ID(l.ID).Delete(&Label{}) return err } @@ -175,7 +175,7 @@ func (l *Label) ReadAll(s *xorm.Session, a web.Auth, search string, page int, pe // @Failure 404 {object} web.HTTPError "Label not found" // @Failure 500 {object} models.Message "Internal error" // @Router /labels/{id} [get] -func (l *Label) ReadOne(s *xorm.Session, a web.Auth) (err error) { +func (l *Label) ReadOne(s *xorm.Session, _ web.Auth) (err error) { label, err := getLabelByIDSimple(s, l.ID) if err != nil { return diff --git a/pkg/models/label_rights.go b/pkg/models/label_rights.go index 196dd10c5..b05b4c704 100644 --- a/pkg/models/label_rights.go +++ b/pkg/models/label_rights.go @@ -40,7 +40,7 @@ func (l *Label) CanRead(s *xorm.Session, a web.Auth) (bool, int, error) { // CanCreate checks if the user can create a label // Currently a dummy. -func (l *Label) CanCreate(s *xorm.Session, a web.Auth) (bool, error) { +func (l *Label) CanCreate(_ *xorm.Session, a web.Auth) (bool, error) { if _, is := a.(*LinkSharing); is { return false, nil } diff --git a/pkg/models/label_task.go b/pkg/models/label_task.go index 13d7e462a..190db7fe2 100644 --- a/pkg/models/label_task.go +++ b/pkg/models/label_task.go @@ -64,7 +64,7 @@ func (LabelTask) TableName() string { // @Failure 404 {object} web.HTTPError "Label not found." // @Failure 500 {object} models.Message "Internal error" // @Router /tasks/{task}/labels/{label} [delete] -func (lt *LabelTask) Delete(s *xorm.Session, a web.Auth) (err error) { +func (lt *LabelTask) Delete(s *xorm.Session, _ web.Auth) (err error) { _, err = s.Delete(&LabelTask{LabelID: lt.LabelID, TaskID: lt.TaskID}) return err } @@ -84,7 +84,7 @@ func (lt *LabelTask) Delete(s *xorm.Session, a web.Auth) (err error) { // @Failure 404 {object} web.HTTPError "The label does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /tasks/{task}/labels [put] -func (lt *LabelTask) Create(s *xorm.Session, a web.Auth) (err error) { +func (lt *LabelTask) Create(s *xorm.Session, _ web.Auth) (err error) { // Check if the label is already added exists, err := s.Exist(&LabelTask{LabelID: lt.LabelID, TaskID: lt.TaskID}) if err != nil { @@ -118,7 +118,7 @@ func (lt *LabelTask) Create(s *xorm.Session, a web.Auth) (err error) { // @Success 200 {array} models.Label "The labels" // @Failure 500 {object} models.Message "Internal error" // @Router /tasks/{task}/labels [get] -func (lt *LabelTask) ReadAll(s *xorm.Session, a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) { +func (lt *LabelTask) ReadAll(s *xorm.Session, a web.Auth, search string, page int, _ int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) { // Check if the user has the right to see the task task := Task{ID: lt.TaskID} canRead, _, err := task.CanRead(s, a) diff --git a/pkg/models/link_sharing.go b/pkg/models/link_sharing.go index a2f6208f8..d91a320cc 100644 --- a/pkg/models/link_sharing.go +++ b/pkg/models/link_sharing.go @@ -169,7 +169,7 @@ func (share *LinkSharing) Create(s *xorm.Session, a web.Auth) (err error) { // @Failure 404 {object} web.HTTPError "Share Link not found." // @Failure 500 {object} models.Message "Internal error" // @Router /projects/{project}/shares/{share} [get] -func (share *LinkSharing) ReadOne(s *xorm.Session, a web.Auth) (err error) { +func (share *LinkSharing) ReadOne(s *xorm.Session, _ web.Auth) (err error) { exists, err := s.Where("id = ?", share.ID).Get(share) if err != nil { return err @@ -269,7 +269,7 @@ func (share *LinkSharing) ReadAll(s *xorm.Session, a web.Auth, search string, pa // @Failure 404 {object} web.HTTPError "Share Link not found." // @Failure 500 {object} models.Message "Internal error" // @Router /projects/{project}/shares/{share} [delete] -func (share *LinkSharing) Delete(s *xorm.Session, a web.Auth) (err error) { +func (share *LinkSharing) Delete(s *xorm.Session, _ web.Auth) (err error) { _, err = s.Where("id = ?", share.ID).Delete(share) return } diff --git a/pkg/models/listeners.go b/pkg/models/listeners.go index f4dcfcd91..183553993 100644 --- a/pkg/models/listeners.go +++ b/pkg/models/listeners.go @@ -75,7 +75,7 @@ func (s *IncreaseTaskCounter) Name() string { } // Handle is executed when the event IncreaseTaskCounter listens on is fired -func (s *IncreaseTaskCounter) Handle(msg *message.Message) (err error) { +func (s *IncreaseTaskCounter) Handle(_ *message.Message) (err error) { return keyvalue.IncrBy(metrics.TaskCountKey, 1) } @@ -89,7 +89,7 @@ func (s *DecreaseTaskCounter) Name() string { } // Handle is executed when the event DecreaseTaskCounter listens on is fired -func (s *DecreaseTaskCounter) Handle(msg *message.Message) (err error) { +func (s *DecreaseTaskCounter) Handle(_ *message.Message) (err error) { return keyvalue.DecrBy(metrics.TaskCountKey, 1) } @@ -480,7 +480,7 @@ func (s *IncreaseProjectCounter) Name() string { return "project.counter.increase" } -func (s *IncreaseProjectCounter) Handle(msg *message.Message) (err error) { +func (s *IncreaseProjectCounter) Handle(_ *message.Message) (err error) { return keyvalue.IncrBy(metrics.ProjectCountKey, 1) } @@ -491,7 +491,7 @@ func (s *DecreaseProjectCounter) Name() string { return "project.counter.decrease" } -func (s *DecreaseProjectCounter) Handle(msg *message.Message) (err error) { +func (s *DecreaseProjectCounter) Handle(_ *message.Message) (err error) { return keyvalue.DecrBy(metrics.ProjectCountKey, 1) } @@ -553,7 +553,7 @@ func (s *IncreaseNamespaceCounter) Name() string { } // Hanlde is executed when the event IncreaseNamespaceCounter listens on is fired -func (s *IncreaseNamespaceCounter) Handle(msg *message.Message) (err error) { +func (s *IncreaseNamespaceCounter) Handle(_ *message.Message) (err error) { return keyvalue.IncrBy(metrics.NamespaceCountKey, 1) } @@ -566,8 +566,8 @@ func (s *DecreaseNamespaceCounter) Name() string { return "namespace.counter.decrease" } -// Hanlde is executed when the event DecreaseNamespaceCounter listens on is fired -func (s *DecreaseNamespaceCounter) Handle(msg *message.Message) (err error) { +// Handle is executed when the event DecreaseNamespaceCounter listens on is fired +func (s *DecreaseNamespaceCounter) Handle(_ *message.Message) (err error) { return keyvalue.DecrBy(metrics.NamespaceCountKey, 1) } @@ -583,8 +583,8 @@ func (s *IncreaseTeamCounter) Name() string { return "team.counter.increase" } -// Hanlde is executed when the event IncreaseTeamCounter listens on is fired -func (s *IncreaseTeamCounter) Handle(msg *message.Message) (err error) { +// Handle is executed when the event IncreaseTeamCounter listens on is fired +func (s *IncreaseTeamCounter) Handle(_ *message.Message) (err error) { return keyvalue.IncrBy(metrics.TeamCountKey, 1) } @@ -597,8 +597,8 @@ func (s *DecreaseTeamCounter) Name() string { return "team.counter.decrease" } -// Hanlde is executed when the event DecreaseTeamCounter listens on is fired -func (s *DecreaseTeamCounter) Handle(msg *message.Message) (err error) { +// Handle is executed when the event DecreaseTeamCounter listens on is fired +func (s *DecreaseTeamCounter) Handle(_ *message.Message) (err error) { return keyvalue.DecrBy(metrics.TeamCountKey, 1) } diff --git a/pkg/models/namespace_rights.go b/pkg/models/namespace_rights.go index 36d964897..f03dbf698 100644 --- a/pkg/models/namespace_rights.go +++ b/pkg/models/namespace_rights.go @@ -50,7 +50,7 @@ func (n *Namespace) CanDelete(s *xorm.Session, a web.Auth) (bool, error) { } // CanCreate checks if the user can create a new namespace -func (n *Namespace) CanCreate(s *xorm.Session, a web.Auth) (bool, error) { +func (n *Namespace) CanCreate(_ *xorm.Session, a web.Auth) (bool, error) { if _, is := a.(*LinkSharing); is { return false, nil } diff --git a/pkg/models/namespace_team.go b/pkg/models/namespace_team.go index 392912778..883256182 100644 --- a/pkg/models/namespace_team.go +++ b/pkg/models/namespace_team.go @@ -124,7 +124,7 @@ func (tn *TeamNamespace) Create(s *xorm.Session, a web.Auth) (err error) { // @Failure 404 {object} web.HTTPError "team or namespace does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{namespaceID}/teams/{teamID} [delete] -func (tn *TeamNamespace) Delete(s *xorm.Session, a web.Auth) (err error) { +func (tn *TeamNamespace) Delete(s *xorm.Session, _ web.Auth) (err error) { // Check if the team exists _, err = GetTeamByID(s, tn.TeamID) @@ -229,7 +229,7 @@ func (tn *TeamNamespace) ReadAll(s *xorm.Session, a web.Auth, search string, pag // @Failure 404 {object} web.HTTPError "Team or namespace does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{namespaceID}/teams/{teamID} [post] -func (tn *TeamNamespace) Update(s *xorm.Session, a web.Auth) (err error) { +func (tn *TeamNamespace) Update(s *xorm.Session, _ web.Auth) (err error) { // Check if the right is valid if err := tn.Right.isValid(); err != nil { diff --git a/pkg/models/namespace_users.go b/pkg/models/namespace_users.go index eda9bfc3e..716df0181 100644 --- a/pkg/models/namespace_users.go +++ b/pkg/models/namespace_users.go @@ -133,7 +133,7 @@ func (nu *NamespaceUser) Create(s *xorm.Session, a web.Auth) (err error) { // @Failure 404 {object} web.HTTPError "user or namespace does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{namespaceID}/users/{userID} [delete] -func (nu *NamespaceUser) Delete(s *xorm.Session, a web.Auth) (err error) { +func (nu *NamespaceUser) Delete(s *xorm.Session, _ web.Auth) (err error) { // Check if the user exists user, err := user2.GetUserByUsername(s, nu.Username) @@ -229,7 +229,7 @@ func (nu *NamespaceUser) ReadAll(s *xorm.Session, a web.Auth, search string, pag // @Failure 404 {object} web.HTTPError "User or namespace does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{namespaceID}/users/{userID} [post] -func (nu *NamespaceUser) Update(s *xorm.Session, a web.Auth) (err error) { +func (nu *NamespaceUser) Update(s *xorm.Session, _ web.Auth) (err error) { // Check if the right is valid if err := nu.Right.isValid(); err != nil { diff --git a/pkg/models/notifications_database.go b/pkg/models/notifications_database.go index 278b5a3b6..9beb78a0d 100644 --- a/pkg/models/notifications_database.go +++ b/pkg/models/notifications_database.go @@ -47,7 +47,7 @@ type DatabaseNotifications struct { // @Failure 403 {object} web.HTTPError "Link shares cannot have notifications." // @Failure 500 {object} models.Message "Internal error" // @Router /notifications [get] -func (d *DatabaseNotifications) ReadAll(s *xorm.Session, a web.Auth, search string, page int, perPage int) (ls interface{}, resultCount int, numberOfEntries int64, err error) { +func (d *DatabaseNotifications) ReadAll(s *xorm.Session, a web.Auth, _ string, page int, perPage int) (ls interface{}, resultCount int, numberOfEntries int64, err error) { if _, is := a.(*LinkSharing); is { return nil, 0, 0, ErrGenericForbidden{} } @@ -79,6 +79,6 @@ func (d *DatabaseNotifications) CanUpdate(s *xorm.Session, a web.Auth) (bool, er // @Failure 404 {object} web.HTTPError "The notification does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /notifications/{id} [post] -func (d *DatabaseNotifications) Update(s *xorm.Session, a web.Auth) (err error) { +func (d *DatabaseNotifications) Update(s *xorm.Session, _ web.Auth) (err error) { return notifications.MarkNotificationAsRead(s, &d.DatabaseNotification, d.Read) } diff --git a/pkg/models/project_team.go b/pkg/models/project_team.go index 6032f2ba4..e89413741 100644 --- a/pkg/models/project_team.go +++ b/pkg/models/project_team.go @@ -135,7 +135,7 @@ func (tl *TeamProject) Create(s *xorm.Session, a web.Auth) (err error) { // @Failure 404 {object} web.HTTPError "Team or project does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /projects/{projectID}/teams/{teamID} [delete] -func (tl *TeamProject) Delete(s *xorm.Session, a web.Auth) (err error) { +func (tl *TeamProject) Delete(s *xorm.Session, _ web.Auth) (err error) { // Check if the team exists _, err = GetTeamByID(s, tl.TeamID) @@ -247,7 +247,7 @@ func (tl *TeamProject) ReadAll(s *xorm.Session, a web.Auth, search string, page // @Failure 404 {object} web.HTTPError "Team or project does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /projects/{projectID}/teams/{teamID} [post] -func (tl *TeamProject) Update(s *xorm.Session, a web.Auth) (err error) { +func (tl *TeamProject) Update(s *xorm.Session, _ web.Auth) (err error) { // Check if the right is valid if err := tl.Right.isValid(); err != nil { diff --git a/pkg/models/project_users.go b/pkg/models/project_users.go index e9053dd94..1cf7cfbbf 100644 --- a/pkg/models/project_users.go +++ b/pkg/models/project_users.go @@ -142,7 +142,7 @@ func (lu *ProjectUser) Create(s *xorm.Session, a web.Auth) (err error) { // @Failure 404 {object} web.HTTPError "user or project does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /projects/{projectID}/users/{userID} [delete] -func (lu *ProjectUser) Delete(s *xorm.Session, a web.Auth) (err error) { +func (lu *ProjectUser) Delete(s *xorm.Session, _ web.Auth) (err error) { // Check if the user exists u, err := user.GetUserByUsername(s, lu.Username) @@ -244,7 +244,7 @@ func (lu *ProjectUser) ReadAll(s *xorm.Session, a web.Auth, search string, page // @Failure 404 {object} web.HTTPError "User or project does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /projects/{projectID}/users/{userID} [post] -func (lu *ProjectUser) Update(s *xorm.Session, a web.Auth) (err error) { +func (lu *ProjectUser) Update(s *xorm.Session, _ web.Auth) (err error) { // Check if the right is valid if err := lu.Right.isValid(); err != nil { diff --git a/pkg/models/saved_filters.go b/pkg/models/saved_filters.go index 9c12f62f0..b2a5958f6 100644 --- a/pkg/models/saved_filters.go +++ b/pkg/models/saved_filters.go @@ -149,7 +149,7 @@ func getSavedFilterSimpleByID(s *xorm.Session, id int64) (sf *SavedFilter, err e // @Failure 403 {object} web.HTTPError "The user does not have access to that saved filter." // @Failure 500 {object} models.Message "Internal error" // @Router /filters/{id} [get] -func (sf *SavedFilter) ReadOne(s *xorm.Session, a web.Auth) error { +func (sf *SavedFilter) ReadOne(s *xorm.Session, _ web.Auth) error { // s already contains almost the full saved filter from the rights check, we only need to add the user u, err := user.GetUserByID(s, sf.OwnerID) sf.Owner = u @@ -169,7 +169,7 @@ func (sf *SavedFilter) ReadOne(s *xorm.Session, a web.Auth) error { // @Failure 404 {object} web.HTTPError "The saved filter does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /filters/{id} [post] -func (sf *SavedFilter) Update(s *xorm.Session, a web.Auth) error { +func (sf *SavedFilter) Update(s *xorm.Session, _ web.Auth) error { origFilter, err := getSavedFilterSimpleByID(s, sf.ID) if err != nil { return err @@ -204,7 +204,7 @@ func (sf *SavedFilter) Update(s *xorm.Session, a web.Auth) error { // @Failure 404 {object} web.HTTPError "The saved filter does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /filters/{id} [delete] -func (sf *SavedFilter) Delete(s *xorm.Session, a web.Auth) error { +func (sf *SavedFilter) Delete(s *xorm.Session, _ web.Auth) error { _, err := s. Where("id = ?", sf.ID). Delete(sf) diff --git a/pkg/models/saved_filters_rights.go b/pkg/models/saved_filters_rights.go index 96fd0e09a..de687d5f6 100644 --- a/pkg/models/saved_filters_rights.go +++ b/pkg/models/saved_filters_rights.go @@ -40,7 +40,7 @@ func (sf *SavedFilter) CanUpdate(s *xorm.Session, auth web.Auth) (bool, error) { } // CanCreate checks if a user has the right to update a saved filter -func (sf *SavedFilter) CanCreate(s *xorm.Session, auth web.Auth) (bool, error) { +func (sf *SavedFilter) CanCreate(_ *xorm.Session, auth web.Auth) (bool, error) { if _, is := auth.(*LinkSharing); is { return false, nil } diff --git a/pkg/models/task_attachment.go b/pkg/models/task_attachment.go index 0251bed0f..1d4e96bfd 100644 --- a/pkg/models/task_attachment.go +++ b/pkg/models/task_attachment.go @@ -94,7 +94,7 @@ func (ta *TaskAttachment) NewAttachment(s *xorm.Session, f io.ReadCloser, realna } // ReadOne returns a task attachment -func (ta *TaskAttachment) ReadOne(s *xorm.Session, a web.Auth) (err error) { +func (ta *TaskAttachment) ReadOne(s *xorm.Session, _ web.Auth) (err error) { exists, err := s.Where("id = ?", ta.ID).Get(ta) if err != nil { return @@ -127,7 +127,7 @@ func (ta *TaskAttachment) ReadOne(s *xorm.Session, a web.Auth) (err error) { // @Failure 404 {object} models.Message "The task does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /tasks/{id}/attachments [get] -func (ta *TaskAttachment) ReadAll(s *xorm.Session, a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) { +func (ta *TaskAttachment) ReadAll(s *xorm.Session, _ web.Auth, _ string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) { attachments := []*TaskAttachment{} limit, start := getLimitFromPageIndex(page, perPage) diff --git a/pkg/models/task_comments.go b/pkg/models/task_comments.go index 0c0514dd3..7d099047f 100644 --- a/pkg/models/task_comments.go +++ b/pkg/models/task_comments.go @@ -101,7 +101,7 @@ func (tc *TaskComment) Create(s *xorm.Session, a web.Auth) (err error) { // @Failure 404 {object} web.HTTPError "The task comment was not found." // @Failure 500 {object} models.Message "Internal error" // @Router /tasks/{taskID}/comments/{commentID} [delete] -func (tc *TaskComment) Delete(s *xorm.Session, a web.Auth) error { +func (tc *TaskComment) Delete(s *xorm.Session, _ web.Auth) error { deleted, err := s. ID(tc.ID). NoAutoCondition(). @@ -135,7 +135,7 @@ func (tc *TaskComment) Delete(s *xorm.Session, a web.Auth) error { // @Failure 404 {object} web.HTTPError "The task comment was not found." // @Failure 500 {object} models.Message "Internal error" // @Router /tasks/{taskID}/comments/{commentID} [post] -func (tc *TaskComment) Update(s *xorm.Session, a web.Auth) error { +func (tc *TaskComment) Update(s *xorm.Session, _ web.Auth) error { updated, err := s. ID(tc.ID). Cols("comment"). @@ -192,7 +192,7 @@ func getTaskCommentSimple(s *xorm.Session, tc *TaskComment) error { // @Failure 404 {object} web.HTTPError "The task comment was not found." // @Failure 500 {object} models.Message "Internal error" // @Router /tasks/{taskID}/comments/{commentID} [get] -func (tc *TaskComment) ReadOne(s *xorm.Session, a web.Auth) (err error) { +func (tc *TaskComment) ReadOne(s *xorm.Session, _ web.Auth) (err error) { err = getTaskCommentSimple(s, tc) if err != nil { return err diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 3f75622e0..6ff52a10b 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -194,7 +194,7 @@ type taskOptions struct { // @Success 200 {array} models.Task "The tasks" // @Failure 500 {object} models.Message "Internal error" // @Router /tasks/all [get] -func (t *Task) ReadAll(s *xorm.Session, a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, totalItems int64, err error) { +func (t *Task) ReadAll(_ *xorm.Session, _ web.Auth, _ string, _ int, _ int) (result interface{}, resultCount int, totalItems int64, err error) { return nil, 0, 0, nil } diff --git a/pkg/models/team_members.go b/pkg/models/team_members.go index f236f5f97..faf176d77 100644 --- a/pkg/models/team_members.go +++ b/pkg/models/team_members.go @@ -88,7 +88,7 @@ func (tm *TeamMember) Create(s *xorm.Session, a web.Auth) (err error) { // @Success 200 {object} models.Message "The user was successfully removed from the team." // @Failure 500 {object} models.Message "Internal error" // @Router /teams/{id}/members/{userID} [delete] -func (tm *TeamMember) Delete(s *xorm.Session, a web.Auth) (err error) { +func (tm *TeamMember) Delete(s *xorm.Session, _ web.Auth) (err error) { total, err := s.Where("team_id = ?", tm.TeamID).Count(&TeamMember{}) if err != nil { @@ -120,7 +120,7 @@ func (tm *TeamMember) Delete(s *xorm.Session, a web.Auth) (err error) { // @Success 200 {object} models.Message "The member right was successfully changed." // @Failure 500 {object} models.Message "Internal error" // @Router /teams/{id}/members/{userID}/admin [post] -func (tm *TeamMember) Update(s *xorm.Session, a web.Auth) (err error) { +func (tm *TeamMember) Update(s *xorm.Session, _ web.Auth) (err error) { // Find the numeric user id user, err := user2.GetUserByUsername(s, tm.Username) if err != nil { diff --git a/pkg/models/teams.go b/pkg/models/teams.go index 12a39095f..cd067dbf4 100644 --- a/pkg/models/teams.go +++ b/pkg/models/teams.go @@ -184,7 +184,7 @@ func addMoreInfoToTeams(s *xorm.Session, teams []*Team) (err error) { // @Failure 403 {object} web.HTTPError "The user does not have access to the team" // @Failure 500 {object} models.Message "Internal error" // @Router /teams/{id} [get] -func (t *Team) ReadOne(s *xorm.Session, a web.Auth) (err error) { +func (t *Team) ReadOne(s *xorm.Session, _ web.Auth) (err error) { team, err := GetTeamByID(s, t.ID) if team != nil { *t = *team @@ -338,7 +338,7 @@ func (t *Team) Delete(s *xorm.Session, a web.Auth) (err error) { // @Failure 400 {object} web.HTTPError "Invalid team object provided." // @Failure 500 {object} models.Message "Internal error" // @Router /teams/{id} [post] -func (t *Team) Update(s *xorm.Session, a web.Auth) (err error) { +func (t *Team) Update(s *xorm.Session, _ web.Auth) (err error) { // Check if we have a name if t.Name == "" { return ErrTeamNameCannotBeEmpty{} diff --git a/pkg/models/teams_rights.go b/pkg/models/teams_rights.go index 3a77ef3ce..258c471fe 100644 --- a/pkg/models/teams_rights.go +++ b/pkg/models/teams_rights.go @@ -22,7 +22,7 @@ import ( ) // CanCreate checks if the user can create a new team -func (t *Team) CanCreate(s *xorm.Session, a web.Auth) (bool, error) { +func (t *Team) CanCreate(_ *xorm.Session, a web.Auth) (bool, error) { if _, is := a.(*LinkSharing); is { return false, nil } diff --git a/pkg/modules/avatar/empty/empty.go b/pkg/modules/avatar/empty/empty.go index 141df10b7..6e2b4b311 100644 --- a/pkg/modules/avatar/empty/empty.go +++ b/pkg/modules/avatar/empty/empty.go @@ -40,6 +40,6 @@ const defaultAvatar string = ` ` // GetAvatar implements getting the avatar method -func (p *Provider) GetAvatar(user *user.User, size int64) (avatar []byte, mimeType string, err error) { +func (p *Provider) GetAvatar(_ *user.User, _ int64) (avatar []byte, mimeType string, err error) { return []byte(defaultAvatar), "image/svg+xml", nil } diff --git a/pkg/modules/background/unsplash/unsplash.go b/pkg/modules/background/unsplash/unsplash.go index a10cadfa0..4f063529f 100644 --- a/pkg/modules/background/unsplash/unsplash.go +++ b/pkg/modules/background/unsplash/unsplash.go @@ -151,7 +151,7 @@ func getUnsplashPhotoInfoByID(photoID string) (photo *Photo, err error) { // @Success 200 {array} background.Image "An array with photos" // @Failure 500 {object} models.Message "Internal error" // @Router /backgrounds/unsplash/search [get] -func (p *Provider) Search(s *xorm.Session, search string, page int64) (result []*background.Image, err error) { +func (p *Provider) Search(_ *xorm.Session, search string, page int64) (result []*background.Image, err error) { // If we don't have a search query, return results from the unsplash featured collection if search == "" { diff --git a/pkg/modules/background/upload/upload.go b/pkg/modules/background/upload/upload.go index 072c0c5bd..b0c5d2569 100644 --- a/pkg/modules/background/upload/upload.go +++ b/pkg/modules/background/upload/upload.go @@ -32,7 +32,7 @@ type Provider struct { } // Search is only used to implement the interface -func (p *Provider) Search(s *xorm.Session, search string, page int64) (result []*background.Image, err error) { +func (p *Provider) Search(_ *xorm.Session, _ string, _ int64) (result []*background.Image, err error) { return } @@ -52,7 +52,7 @@ func (p *Provider) Search(s *xorm.Session, search string, page int64) (result [] // @Failure 404 {object} models.Message "The project does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /projects/{id}/backgrounds/upload [put] -func (p *Provider) Set(s *xorm.Session, img *background.Image, project *models.Project, auth web.Auth) (err error) { +func (p *Provider) Set(s *xorm.Session, img *background.Image, project *models.Project, _ web.Auth) (err error) { // Remove the old background if one exists err = project.DeleteBackgroundFileIfExists() if err != nil { diff --git a/pkg/routes/caldav/listStorageProvider.go b/pkg/routes/caldav/listStorageProvider.go index 88841670f..cdf9f925d 100644 --- a/pkg/routes/caldav/listStorageProvider.go +++ b/pkg/routes/caldav/listStorageProvider.go @@ -51,7 +51,7 @@ type VikunjaCaldavProjectStorage struct { } // GetResources returns either all projects, links to the principal, or only one project, depending on the request -func (vcls *VikunjaCaldavProjectStorage) GetResources(rpath string, withChildren bool) ([]data.Resource, error) { +func (vcls *VikunjaCaldavProjectStorage) GetResources(rpath string, _ bool) ([]data.Resource, error) { // It looks like we need to have the same handler for returning both the calendar home set and the user principal // Since the client seems to ignore the whatever is being returned in the first request and just makes a second one @@ -166,7 +166,7 @@ func (vcls *VikunjaCaldavProjectStorage) GetResourcesByList(rpaths []string) ([] } // GetResourcesByFilters fetches a project of resources with a filter -func (vcls *VikunjaCaldavProjectStorage) GetResourcesByFilters(rpath string, filters *data.ResourceFilter) ([]data.Resource, error) { +func (vcls *VikunjaCaldavProjectStorage) GetResourcesByFilters(rpath string, _ *data.ResourceFilter) ([]data.Resource, error) { // If we already have a project saved, that means the user is making a REPORT request to find out if // anything changed, in that case we need to return all tasks. @@ -359,7 +359,7 @@ func (vcls *VikunjaCaldavProjectStorage) UpdateResource(rpath, content string) ( } // DeleteResource deletes a resource -func (vcls *VikunjaCaldavProjectStorage) DeleteResource(rpath string) error { +func (vcls *VikunjaCaldavProjectStorage) DeleteResource(_ string) error { if vcls.task != nil { s := db.NewSession() defer s.Close() diff --git a/pkg/user/listeners.go b/pkg/user/listeners.go index 0e96969d4..20d9282f2 100644 --- a/pkg/user/listeners.go +++ b/pkg/user/listeners.go @@ -39,7 +39,7 @@ func (s *IncreaseUserCounter) Name() string { return "increase.user.counter" } -// Hanlde is executed when the event IncreaseUserCounter listens on is fired -func (s *IncreaseUserCounter) Handle(msg *message.Message) (err error) { +// Handle is executed when the event IncreaseUserCounter listens on is fired +func (s *IncreaseUserCounter) Handle(_ *message.Message) (err error) { return keyvalue.IncrBy(metrics.UserCountKey, 1) } From 33f0d0f85a7fdfd509bc8a4aad26df95c064468c Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 24 Mar 2023 19:24:25 +0100 Subject: [PATCH 10/16] fix: update xgo in dockerfile to 1.20.2 Resolves https://kolaente.dev/vikunja/api/issues/1445 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 39f0b3cdd..c873d6ee0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # │─││ │││ │ │ # ┘─┘┘─┘┘┘─┘┘─┘ -FROM --platform=$BUILDPLATFORM techknowlogick/xgo:go-1.20.0 AS builder +FROM --platform=$BUILDPLATFORM techknowlogick/xgo:go-1.20.x AS builder RUN go install github.com/magefile/mage@latest && \ mv /go/bin/mage /usr/local/go/bin From 5961e56d1603f52d50aa5bb0f76a4ee0d909f104 Mon Sep 17 00:00:00 2001 From: cernst Date: Fri, 24 Mar 2023 18:34:48 +0000 Subject: [PATCH 11/16] fix(caldav): Do not create label if it exists by title (#1444) Resolves https://kolaente.dev/vikunja/api/issues/1435 Co-authored-by: ce72 Reviewed-on: https://kolaente.dev/vikunja/api/pulls/1444 Co-authored-by: cernst Co-committed-by: cernst --- pkg/routes/caldav/listStorageProvider.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/routes/caldav/listStorageProvider.go b/pkg/routes/caldav/listStorageProvider.go index cdf9f925d..91373cf51 100644 --- a/pkg/routes/caldav/listStorageProvider.go +++ b/pkg/routes/caldav/listStorageProvider.go @@ -411,13 +411,13 @@ func persistLabels(s *xorm.Session, a web.Auth, task *models.Task, labels []*mod return err } - labelMap := make(map[int64]*models.Label) + labelMap := make(map[string]*models.Label) for _, l := range existingLabels { - labelMap[l.ID] = &l.Label + labelMap[l.Title] = &l.Label } for _, label := range labels { - if l, has := labelMap[label.ID]; has { + if l, has := labelMap[label.Title]; has { *label = *l continue } From 7987efcefc7135752e652c9bd05ed666802fd0ae Mon Sep 17 00:00:00 2001 From: renovate Date: Sat, 18 Mar 2023 11:01:39 +0000 Subject: [PATCH 12/16] fix(deps): update module github.com/wneessen/go-mail to v0.3.9 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 0a12018d0..73ff15d4d 100644 --- a/go.mod +++ b/go.mod @@ -62,7 +62,7 @@ require ( github.com/tkuchiki/go-timezone v0.2.2 github.com/ulule/limiter/v3 v3.11.1 github.com/vectordotdev/go-datemath v0.1.1-0.20220323213446-f3954d0b18ae - github.com/wneessen/go-mail v0.3.8 + github.com/wneessen/go-mail v0.3.9 github.com/yuin/goldmark v1.5.4 golang.org/x/crypto v0.7.0 golang.org/x/image v0.6.0 diff --git a/go.sum b/go.sum index 2f6af8fd7..46d3b9b7b 100644 --- a/go.sum +++ b/go.sum @@ -719,6 +719,8 @@ github.com/vectordotdev/go-datemath v0.1.1-0.20220323213446-f3954d0b18ae h1:oyiy github.com/vectordotdev/go-datemath v0.1.1-0.20220323213446-f3954d0b18ae/go.mod h1:PnwzbSst7KD3vpBzzlntZU5gjVa455Uqa5QPiKSYJzQ= github.com/wneessen/go-mail v0.3.8 h1:ja5D/o/RVwrtRIYFlrO7GmtcjDNeMakGQuwQRZYv0JM= github.com/wneessen/go-mail v0.3.8/go.mod h1:m25lkU2GYQnlVr6tdwK533/UXxo57V0kLOjaFYmub0E= +github.com/wneessen/go-mail v0.3.9 h1:Q4DbCk3htT5DtDWKeMgNXCiHc4bBY/vv/XQPT6XDXzc= +github.com/wneessen/go-mail v0.3.9/go.mod h1:zxOlafWCP/r6FEhAaRgH4IC1vg2YXxO0Nar9u0IScZ8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= From 9590b82c11852666524eeab562988226574a1b1c Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 24 Mar 2023 20:35:12 +0100 Subject: [PATCH 13/16] feat: add logging options to mailer settings --- config.yml.sample | 4 ++ docs/content/doc/setup/config.md | 22 ++++++++++ pkg/config/config.go | 4 ++ pkg/log/mail_logger.go | 70 ++++++++++++++++++++++++++++++++ pkg/mail/mail.go | 2 + 5 files changed, 102 insertions(+) create mode 100644 pkg/log/mail_logger.go diff --git a/config.yml.sample b/config.yml.sample index 44fb3d44c..db30341e2 100644 --- a/config.yml.sample +++ b/config.yml.sample @@ -168,6 +168,10 @@ log: events: "off" # The log level for event log messages. Possible values (case-insensitive) are ERROR, INFO, DEBUG. eventslevel: "info" + # Whether or not to log mail log messages. This will not log mail contents. Possible values are stdout, stderr, file or off to disable mail-related logging. + mail: "off" + # The log level for mail log messages. Possible values (case-insensitive) are ERROR, WARNING, INFO, DEBUG. + maillevel: "info" ratelimit: # whether or not to enable the rate limit diff --git a/docs/content/doc/setup/config.md b/docs/content/doc/setup/config.md index 11103546e..ff63fde5e 100644 --- a/docs/content/doc/setup/config.md +++ b/docs/content/doc/setup/config.md @@ -871,6 +871,28 @@ Full path: `log.eventslevel` Environment path: `VIKUNJA_LOG_EVENTSLEVEL` +### mail + +Whether or not to log mail log messages. This will not log mail contents. Possible values are stdout, stderr, file or off to disable mail-related logging. + +Default: `off` + +Full path: `log.mail` + +Environment path: `VIKUNJA_LOG_MAIL` + + +### maillevel + +The log level for mail log messages. Possible values (case-insensitive) are ERROR, WARNING, INFO, DEBUG. + +Default: `info` + +Full path: `log.maillevel` + +Environment path: `VIKUNJA_LOG_MAILLEVEL` + + --- ## ratelimit diff --git a/pkg/config/config.go b/pkg/config/config.go index c081b277c..993e8a2c4 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -118,6 +118,8 @@ const ( LogPath Key = `log.path` LogEvents Key = `log.events` LogEventsLevel Key = `log.eventslevel` + LogMail Key = `log.mail` + LogMailLevel Key = `log.maillevel` RateLimitEnabled Key = `ratelimit.enabled` RateLimitKind Key = `ratelimit.kind` @@ -351,6 +353,8 @@ func InitDefaultConfig() { LogPath.setDefault(ServiceRootpath.GetString() + "/logs") LogEvents.setDefault("off") LogEventsLevel.setDefault("INFO") + LogMail.setDefault("off") + LogMailLevel.setDefault("INFO") // Rate Limit RateLimitEnabled.setDefault(false) RateLimitKind.setDefault("user") diff --git a/pkg/log/mail_logger.go b/pkg/log/mail_logger.go new file mode 100644 index 000000000..09acf52dc --- /dev/null +++ b/pkg/log/mail_logger.go @@ -0,0 +1,70 @@ +package log + +import ( + "code.vikunja.io/api/pkg/config" + "github.com/op/go-logging" + "strings" + "time" + "xorm.io/xorm/log" +) + +type MailLogger struct { + logger *logging.Logger + level log.LogLevel +} + +const mailFormat = `%{color}%{time:` + time.RFC3339Nano + `}: %{level}` + "\t" + `▶ [MAIL] %{id:03x}%{color:reset} %{message}` +const mailLogModule = `vikunja_mail` + +func NewMailLogger() *MailLogger { + lvl := strings.ToUpper(config.LogMailLevel.GetString()) + level, err := logging.LogLevel(lvl) + if err != nil { + Criticalf("Error setting database log level: %s", err.Error()) + } + + mailLogger := &MailLogger{ + logger: logging.MustGetLogger(mailLogModule), + } + + logBackend := logging.NewLogBackend(GetLogWriter("mail"), "", 0) + backend := logging.NewBackendFormatter(logBackend, logging.MustStringFormatter(mailFormat+"\n")) + + backendLeveled := logging.AddModuleLevel(backend) + backendLeveled.SetLevel(level, mailLogModule) + + mailLogger.logger.SetBackend(backendLeveled) + + switch level { + case logging.CRITICAL: + case logging.ERROR: + mailLogger.level = log.LOG_ERR + case logging.WARNING: + mailLogger.level = log.LOG_WARNING + case logging.NOTICE: + case logging.INFO: + mailLogger.level = log.LOG_INFO + case logging.DEBUG: + mailLogger.level = log.LOG_DEBUG + default: + mailLogger.level = log.LOG_OFF + } + + return mailLogger +} + +func (m *MailLogger) Errorf(format string, v ...interface{}) { + m.logger.Errorf(format, v...) +} + +func (m *MailLogger) Warnf(format string, v ...interface{}) { + m.logger.Warningf(format, v...) +} + +func (m *MailLogger) Infof(format string, v ...interface{}) { + m.logger.Infof(format, v...) +} + +func (m *MailLogger) Debugf(format string, v ...interface{}) { + m.logger.Debugf(format, v...) +} diff --git a/pkg/mail/mail.go b/pkg/mail/mail.go index 4ac2c5ae0..1d4329eff 100644 --- a/pkg/mail/mail.go +++ b/pkg/mail/mail.go @@ -56,6 +56,8 @@ func getClient() (*mail.Client, error) { ServerName: config.MailerHost.GetString(), }), mail.WithTimeout((config.MailerQueueTimeout.GetDuration() + 3) * time.Second), // 3s more for us to close before mail server timeout + mail.WithLogger(log.NewMailLogger()), + mail.WithDebugLog(), } if config.MailerForceSSL.GetBool() { From f0dcce702f03f237ecde107a7ba62f61e2c3e313 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 24 Mar 2023 23:13:09 +0100 Subject: [PATCH 14/16] fix: lint --- pkg/log/mail_logger.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/log/mail_logger.go b/pkg/log/mail_logger.go index 09acf52dc..ec1478638 100644 --- a/pkg/log/mail_logger.go +++ b/pkg/log/mail_logger.go @@ -1,10 +1,11 @@ package log import ( - "code.vikunja.io/api/pkg/config" - "github.com/op/go-logging" "strings" "time" + + "code.vikunja.io/api/pkg/config" + "github.com/op/go-logging" "xorm.io/xorm/log" ) From f4e12dab273474c0eb27f59c00faa828bb86522c Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 25 Mar 2023 13:16:39 +0100 Subject: [PATCH 15/16] fix: add missing license header --- pkg/log/mail_logger.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/log/mail_logger.go b/pkg/log/mail_logger.go index ec1478638..dd323488e 100644 --- a/pkg/log/mail_logger.go +++ b/pkg/log/mail_logger.go @@ -1,3 +1,19 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-2021 Vikunja and contributors. All rights reserved. +// +// 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. +// +// 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 Affero General Public Licensee for more details. +// +// You should have received a copy of the GNU Affero General Public Licensee +// along with this program. If not, see . + package log import ( From 84c3d0ef6dc383acaa2d1f9aa0b628e52284bf42 Mon Sep 17 00:00:00 2001 From: renovate Date: Sat, 25 Mar 2023 18:02:07 +0000 Subject: [PATCH 16/16] fix(deps): update github.com/gocarina/gocsv digest to 9a18a84 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 73ff15d4d..c16c4111b 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/getsentry/sentry-go v0.19.0 github.com/go-sql-driver/mysql v1.7.0 github.com/go-testfixtures/testfixtures/v3 v3.8.1 - github.com/gocarina/gocsv v0.0.0-20230226133904-70c27cb2918a + github.com/gocarina/gocsv v0.0.0-20230325173030-9a18a846a479 github.com/golang-jwt/jwt/v4 v4.5.0 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 github.com/google/uuid v1.3.0 diff --git a/go.sum b/go.sum index 46d3b9b7b..edae000a3 100644 --- a/go.sum +++ b/go.sum @@ -219,6 +219,8 @@ github.com/go-testfixtures/testfixtures/v3 v3.8.1 h1:uonwvepqRvSgddcrReZQhojTlWl github.com/go-testfixtures/testfixtures/v3 v3.8.1/go.mod h1:Kdu7YeMC0KRXVHdaQ91Vmx3pcjoTF63h4f1qTJDdXLA= github.com/gocarina/gocsv v0.0.0-20230226133904-70c27cb2918a h1:/5o1ejt5M0fNAN2lU1NBLtPzUSZru689EWJq01ptr+E= github.com/gocarina/gocsv v0.0.0-20230226133904-70c27cb2918a/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI= +github.com/gocarina/gocsv v0.0.0-20230325173030-9a18a846a479 h1:KaCpc4e48emF9hYmMB9INyfpGJHAZxEAS9EqWFkpTig= +github.com/gocarina/gocsv v0.0.0-20230325173030-9a18a846a479/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI= github.com/goccy/go-json v0.8.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk= github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=