From 7a74e491dab14090f57dd272562e6b03ce1acdca Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 17 Oct 2023 20:35:05 +0200 Subject: [PATCH] fix(webhooks): lint --- pkg/migration/20230913202615.go | 3 ++- pkg/models/listeners.go | 12 ++++++------ pkg/models/webhooks.go | 15 ++++++++------- pkg/routes/api/v1/webhooks.go | 3 ++- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/pkg/migration/20230913202615.go b/pkg/migration/20230913202615.go index 5eceba38d1f..206d4555a2a 100644 --- a/pkg/migration/20230913202615.go +++ b/pkg/migration/20230913202615.go @@ -17,8 +17,9 @@ package migration import ( - "src.techknowlogick.com/xormigrate" "time" + + "src.techknowlogick.com/xormigrate" "xorm.io/xorm" ) diff --git a/pkg/models/listeners.go b/pkg/models/listeners.go index 397ab51b162..071f78d2048 100644 --- a/pkg/models/listeners.go +++ b/pkg/models/listeners.go @@ -648,11 +648,11 @@ func getProjectIDFromAnyEvent(eventPayload map[string]interface{}) int64 { if task, has := eventPayload["task"]; has { t := task.(map[string]interface{}) if projectID, has := t["project_id"]; has { - switch projectID.(type) { + switch v := projectID.(type) { case int64: - return projectID.(int64) + return v case float64: - return int64(projectID.(float64)) + return int64(v) } return projectID.(int64) } @@ -661,11 +661,11 @@ func getProjectIDFromAnyEvent(eventPayload map[string]interface{}) int64 { if project, has := eventPayload["project"]; has { t := project.(map[string]interface{}) if projectID, has := t["id"]; has { - switch projectID.(type) { + switch v := projectID.(type) { case int64: - return projectID.(int64) + return v case float64: - return int64(projectID.(float64)) + return int64(v) } return projectID.(int64) } diff --git a/pkg/models/webhooks.go b/pkg/models/webhooks.go index 9dfcd9e347f..87a1dc3fc85 100644 --- a/pkg/models/webhooks.go +++ b/pkg/models/webhooks.go @@ -18,12 +18,6 @@ package models import ( "bytes" - "code.vikunja.io/api/pkg/config" - "code.vikunja.io/api/pkg/events" - "code.vikunja.io/api/pkg/log" - "code.vikunja.io/api/pkg/user" - "code.vikunja.io/api/pkg/version" - "code.vikunja.io/web" "crypto/hmac" "crypto/sha256" "encoding/base64" @@ -34,6 +28,13 @@ import ( "sort" "sync" "time" + + "code.vikunja.io/api/pkg/config" + "code.vikunja.io/api/pkg/events" + "code.vikunja.io/api/pkg/log" + "code.vikunja.io/api/pkg/user" + "code.vikunja.io/api/pkg/version" + "code.vikunja.io/web" "xorm.io/xorm" ) @@ -99,7 +100,7 @@ func GetAvailableWebhookEvents() []string { // Create creates a webhook target // @Summary Create a webhook target -// @Description Create a webhook target which recieves POST requests about specified events from a project. +// @Description Create a webhook target which receives POST requests about specified events from a project. // @tags webhooks // @Accept json // @Produce json diff --git a/pkg/routes/api/v1/webhooks.go b/pkg/routes/api/v1/webhooks.go index 7c0a435c0b5..91ec993637b 100644 --- a/pkg/routes/api/v1/webhooks.go +++ b/pkg/routes/api/v1/webhooks.go @@ -17,9 +17,10 @@ package v1 import ( + "net/http" + "code.vikunja.io/api/pkg/models" "github.com/labstack/echo/v4" - "net/http" ) // GetAvailableWebhookEvents returns a list of all possible webhook target events