feat(pretix-webook): Add webhook route, db-entity
This commit is contained in:
parent
304f706dd6
commit
78968c7199
7 changed files with 61 additions and 5 deletions
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch Package",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "auto",
|
||||||
|
"program": "src/main.go"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
15
src/app/controller/webhook_controller.go
Normal file
15
src/app/controller/webhook_controller.go
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"ulmer-furs.de/pretix-proxy/v2/entities"
|
||||||
|
)
|
||||||
|
|
||||||
|
func PostPretix(c *fiber.Ctx) error {
|
||||||
|
data := new(entities.Pretix_Webhook)
|
||||||
|
if err := c.BodyParser(data); err != nil {
|
||||||
|
return c.Status(fiber.ErrBadRequest.Code).SendString(err.Error())
|
||||||
|
}
|
||||||
|
//TODO: Update attendies from pretix
|
||||||
|
return c.SendStatus(fiber.StatusOK)
|
||||||
|
}
|
|
@ -8,6 +8,8 @@ import (
|
||||||
func PublicRoutes(app *fiber.App) {
|
func PublicRoutes(app *fiber.App) {
|
||||||
apiv1 := app.Group("/api/v1/public")
|
apiv1 := app.Group("/api/v1/public")
|
||||||
attendies := apiv1.Group("/attendies")
|
attendies := apiv1.Group("/attendies")
|
||||||
|
webhooks := apiv1.Group("/webhooks")
|
||||||
|
webhooks.Post("/pretix", controller.PostPretix)
|
||||||
apiv1.Post("/login", controller.LoginUser)
|
apiv1.Post("/login", controller.LoginUser)
|
||||||
apiv1.Get("/event", controller.ReturnAllEventsPublic)
|
apiv1.Get("/event", controller.ReturnAllEventsPublic)
|
||||||
apiv1.Get("/ping", controller.Ping)
|
apiv1.Get("/ping", controller.Ping)
|
||||||
|
|
|
@ -16,7 +16,7 @@ func Connect() error {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Database.AutoMigrate(&entities.Db_Event{}, &entities.User{})
|
Database.AutoMigrate(&entities.Db_Event{}, &entities.Db_Attendies{}, &entities.User{})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
15
src/entities/db_attendies.go
Normal file
15
src/entities/db_attendies.go
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package entities
|
||||||
|
|
||||||
|
import "gorm.io/gorm"
|
||||||
|
|
||||||
|
type Db_Attendies struct {
|
||||||
|
gorm.Model
|
||||||
|
Nickname string `gorm:"column:nickname;not null"`
|
||||||
|
Event Db_Event `gorm:"column:event_id;not null"`
|
||||||
|
IsSuiter bool `grom:"column:is_suiter;not null"`
|
||||||
|
IsGuest bool `gorm:"column:is_guest;not null"`
|
||||||
|
IsSpotter bool `gorm:"column:is_spotter;not null"`
|
||||||
|
IsPhotograph bool `gorm:"column:is_photograph;not null"`
|
||||||
|
IsSpecialAnimal bool `gorm:"column:is_special_animal;not null"`
|
||||||
|
IsPublic bool `gorm:"column:is_public;not null"`
|
||||||
|
}
|
9
src/entities/webhooks.go
Normal file
9
src/entities/webhooks.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package entities
|
||||||
|
|
||||||
|
type Pretix_Webhook struct {
|
||||||
|
NotificationId int `json:"notification_id"`
|
||||||
|
Organizer string `json:"organizer"`
|
||||||
|
Event string `json:"event"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
Action string `json:"action"`
|
||||||
|
}
|
|
@ -4,8 +4,12 @@ go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-playground/validator/v10 v10.15.4
|
github.com/go-playground/validator/v10 v10.15.4
|
||||||
|
github.com/gofiber/contrib/jwt v1.0.7
|
||||||
github.com/gofiber/fiber/v2 v2.51.0
|
github.com/gofiber/fiber/v2 v2.51.0
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.1.0
|
||||||
|
github.com/jinzhu/copier v0.4.0
|
||||||
github.com/joho/godotenv v1.5.1
|
github.com/joho/godotenv v1.5.1
|
||||||
|
golang.org/x/crypto v0.15.0
|
||||||
gorm.io/driver/sqlite v1.5.3
|
gorm.io/driver/sqlite v1.5.3
|
||||||
gorm.io/gorm v1.25.4
|
gorm.io/gorm v1.25.4
|
||||||
)
|
)
|
||||||
|
@ -15,11 +19,7 @@ require (
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/gofiber/contrib/jwt v1.0.7 // indirect
|
|
||||||
github.com/golang-jwt/jwt/v5 v5.1.0 // indirect
|
|
||||||
github.com/jinzhu/copier v0.4.0 // indirect
|
|
||||||
github.com/leodido/go-urn v1.2.4 // indirect
|
github.com/leodido/go-urn v1.2.4 // indirect
|
||||||
golang.org/x/crypto v0.15.0 // indirect
|
|
||||||
golang.org/x/net v0.10.0 // indirect
|
golang.org/x/net v0.10.0 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue