fix(webhooks): lint

This commit is contained in:
kolaente 2023-10-17 20:35:05 +02:00
parent 2c84cec044
commit 7a74e491da
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 18 additions and 15 deletions

View File

@ -17,8 +17,9 @@
package migration package migration
import ( import (
"src.techknowlogick.com/xormigrate"
"time" "time"
"src.techknowlogick.com/xormigrate"
"xorm.io/xorm" "xorm.io/xorm"
) )

View File

@ -648,11 +648,11 @@ func getProjectIDFromAnyEvent(eventPayload map[string]interface{}) int64 {
if task, has := eventPayload["task"]; has { if task, has := eventPayload["task"]; has {
t := task.(map[string]interface{}) t := task.(map[string]interface{})
if projectID, has := t["project_id"]; has { if projectID, has := t["project_id"]; has {
switch projectID.(type) { switch v := projectID.(type) {
case int64: case int64:
return projectID.(int64) return v
case float64: case float64:
return int64(projectID.(float64)) return int64(v)
} }
return projectID.(int64) return projectID.(int64)
} }
@ -661,11 +661,11 @@ func getProjectIDFromAnyEvent(eventPayload map[string]interface{}) int64 {
if project, has := eventPayload["project"]; has { if project, has := eventPayload["project"]; has {
t := project.(map[string]interface{}) t := project.(map[string]interface{})
if projectID, has := t["id"]; has { if projectID, has := t["id"]; has {
switch projectID.(type) { switch v := projectID.(type) {
case int64: case int64:
return projectID.(int64) return v
case float64: case float64:
return int64(projectID.(float64)) return int64(v)
} }
return projectID.(int64) return projectID.(int64)
} }

View File

@ -18,12 +18,6 @@ package models
import ( import (
"bytes" "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/hmac"
"crypto/sha256" "crypto/sha256"
"encoding/base64" "encoding/base64"
@ -34,6 +28,13 @@ import (
"sort" "sort"
"sync" "sync"
"time" "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" "xorm.io/xorm"
) )
@ -99,7 +100,7 @@ func GetAvailableWebhookEvents() []string {
// Create creates a webhook target // Create creates a webhook target
// @Summary Create 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 // @tags webhooks
// @Accept json // @Accept json
// @Produce json // @Produce json

View File

@ -17,9 +17,10 @@
package v1 package v1
import ( import (
"net/http"
"code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/models"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"net/http"
) )
// GetAvailableWebhookEvents returns a list of all possible webhook target events // GetAvailableWebhookEvents returns a list of all possible webhook target events