diff --git a/scnserver/TODO.md b/scnserver/TODO.md index 42292ee..34a4986 100644 --- a/scnserver/TODO.md +++ b/scnserver/TODO.md @@ -6,75 +6,57 @@ #### BEFORE RELEASE - - migration script for existing data - apply local deletion in (my) app - delete excessive dockerwatch messages (directly in db?) + - migrate old data + + - in my script: use `srvname` for sendername + + - switch send script everywhere (we can use the new server, but we need to send correct channels) - app-store link in HTML - - route to re-check all pro-token (for me) - - deploy - - error logging as goroutine, gets all errors via channel, - (channel buffered - nonblocking send, second channel that gets a message when sender failed ) - (then all errors end up in _second_ sqlite table) - due to message channel etc everything is non blocking and cant fail in main - - - => implement proper error logging in goext, kinda combines zerolog and wrapped-errors - copy basic code from bringman, but remove all bm specific stuff and make it abstract - Register(ErrType) methods, errtypes then as structs - log.xxx package with same interface as zerolog - - - jobs to clear requests-db to only keep X entries... (logs-db already exists) - - - /send endpoint should be compatible with the [ webhook ] notifier of uptime-kuma - (or add another /kuma endpoint) - -> https://webhook.site/ - - - endpoint to list all servernames of user (distinct select) - - ios purchase verification - - move to KeyToken model - * [X] User can have multiple keys with different permissions - * [X] compat simply uses default-keys - * [X] CRUD routes for keys - * [X] KeyToken.messagecounter - * [x] update old-data migration to create token-keys - * [x] unit tests - - - We no longer have a route to reshuffle all keys (previously in updateUser), add a /user/:uid/keys/reset ? - Would delete all existing keys and create 3 new ones? - - - TODO-comments - - - multistage build - -#### PERSONAL - - - in my script: use `srvname` for sendername - - - switch send script everywhere (we can use the new server, but we need to send correct channels) - - - do i need bool2db()? it seems to work for keytokens without them? - #### UNSURE - (?) default-priority for channels - - (?) ack/read deliveries && return ack-count (? or not, how to query?) - - (?) "login" on website and list/search/filter messages - (?) make channels deleteable (soft-delete) (what do with messages in channel?) - (?) desktop client for notifications -- (?) add querylog (similar to requestlog/errorlog) - only for main-db + - (?) add querylog (similar to requestlog/errorlog) - only for main-db #### LATER + - do i need bool2db()? it seems to work for keytokens without them? + + - We no longer have a route to reshuffle all keys (previously in updateUser), add a /user/:uid/keys/reset ? + Would delete all existing keys and create 3 new ones? + + - error logging as goroutine, gets all errors via channel, + (channel buffered - nonblocking send, second channel that gets a message when sender failed ) + (then all errors end up in _second_ sqlite table) + due to message channel etc everything is non blocking and cant fail in main + + - => implement proper error logging in goext, kinda combines zerolog and wrapped-errors + copy basic code from bringman, but remove all bm specific stuff and make it abstract + Register(ErrType) methods, errtypes then as structs + log.xxx package with same interface as zerolog + + - jobs to clear error-db to only keep X entries... (requests-db already exists) + + - route to re-check all pro-token (for me) + + - /send endpoint should be compatible with the [ webhook ] notifier of uptime-kuma + (or add another /kuma endpoint) + -> https://webhook.site/ + + - endpoint to list all servernames of user (distinct select) + - weblogin, webapp, ... - Pagination for ListChannels / ListSubscriptions / ListClients / ListChannelSubscriptions / ListUserSubscriptions @@ -86,11 +68,6 @@ - use job superclass (copy from isi/bnet/?), reduce duplicate code - - golang ci - - - cannot open sqlite in dbbrowsr (cannot parse schema?) - -> https://github.com/sqlitebrowser/sqlitebrowser/issues/292 -> https://github.com/sqlitebrowser/sqlitebrowser/issues/29266 - #### FUTURE - Remove compat, especially do not create compat id for every new message... diff --git a/scnserver/api/ginresp/resp.go b/scnserver/api/ginresp/resp.go index 2243611..0d40338 100644 --- a/scnserver/api/ginresp/resp.go +++ b/scnserver/api/ginresp/resp.go @@ -4,7 +4,6 @@ import ( scn "blackforestbytes.com/simplecloudnotifier" "blackforestbytes.com/simplecloudnotifier/api/apierr" "blackforestbytes.com/simplecloudnotifier/api/apihighlight" - "encoding/json" "fmt" "github.com/gin-gonic/gin" "github.com/rs/zerolog/log" diff --git a/scnserver/api/handler/apiChannel.go b/scnserver/api/handler/apiChannel.go index a6a430c..8e0bbb1 100644 --- a/scnserver/api/handler/apiChannel.go +++ b/scnserver/api/handler/apiChannel.go @@ -27,7 +27,7 @@ import ( // @ID api-channels-list // @Tags API-v2 // -// @Param uid path string true "UserID" +// @Param uid path string true "UserID" // @Param selector query string false "Filter channels (default: owned)" Enums(owned, subscribed, all, subscribed_any, all_any) // // @Success 200 {object} handler.ListChannels.response @@ -162,7 +162,7 @@ func (h APIHandler) GetChannel(g *gin.Context) ginresp.HTTPResponse { // @ID api-channels-create // @Tags API-v2 // -// @Param uid path string true "UserID" +// @Param uid path string true "UserID" // @Param post_body body handler.CreateChannel.body false " " // // @Success 200 {object} models.ChannelWithSubscriptionJSON @@ -260,8 +260,8 @@ func (h APIHandler) CreateChannel(g *gin.Context) ginresp.HTTPResponse { // @ID api-channels-update // @Tags API-v2 // -// @Param uid path string true "UserID" -// @Param cid path string true "ChannelID" +// @Param uid path string true "UserID" +// @Param cid path string true "ChannelID" // // @Param subscribe_key body string false "Send `true` to create a new subscribe_key" // @Param send_key body string false "Send `true` to create a new send_key" @@ -378,8 +378,8 @@ func (h APIHandler) UpdateChannel(g *gin.Context) ginresp.HTTPResponse { // @Tags API-v2 // // @Param query_data query handler.ListChannelMessages.query false " " -// @Param uid path string true "UserID" -// @Param cid path string true "ChannelID" +// @Param uid path string true "UserID" +// @Param cid path string true "ChannelID" // // @Success 200 {object} handler.ListChannelMessages.response // @Failure 400 {object} ginresp.apiError "supplied values/parameters cannot be parsed / are invalid" diff --git a/scnserver/api/handler/apiClient.go b/scnserver/api/handler/apiClient.go index 59b0f25..8757f73 100644 --- a/scnserver/api/handler/apiClient.go +++ b/scnserver/api/handler/apiClient.go @@ -103,7 +103,7 @@ func (h APIHandler) GetClient(g *gin.Context) ginresp.HTTPResponse { // @ID api-clients-create // @Tags API-v2 // -// @Param uid path string true "UserID" +// @Param uid path string true "UserID" // // @Param post_body body handler.AddClient.body false " " // @@ -214,8 +214,8 @@ func (h APIHandler) DeleteClient(g *gin.Context) ginresp.HTTPResponse { // @ID api-client-update // @Tags API-v2 // -// @Param uid path string true "UserID" -// @Param cid path string true "ClientID" +// @Param uid path string true "UserID" +// @Param cid path string true "ClientID" // // @Param clientname body string false "Change the clientname (send an empty string to clear it)" // @Param pro_token body string false "Send a verification of premium purchase" diff --git a/scnserver/api/handler/apiKeyToken.go b/scnserver/api/handler/apiKeyToken.go index 2c81e5d..63726b3 100644 --- a/scnserver/api/handler/apiKeyToken.go +++ b/scnserver/api/handler/apiKeyToken.go @@ -106,8 +106,8 @@ func (h APIHandler) GetUserKey(g *gin.Context) ginresp.HTTPResponse { // @ID api-tokenkeys-update // @Tags API-v2 // -// @Param uid path string true "UserID" -// @Param kid path string true "TokenKeyID" +// @Param uid path string true "UserID" +// @Param kid path string true "TokenKeyID" // // @Param post_body body handler.UpdateUserKey.body false " " // @@ -204,7 +204,7 @@ func (h APIHandler) UpdateUserKey(g *gin.Context) ginresp.HTTPResponse { // @ID api-tokenkeys-create // @Tags API-v2 // -// @Param uid path string true "UserID" +// @Param uid path string true "UserID" // // @Param post_body body handler.CreateUserKey.body false " " // diff --git a/scnserver/api/handler/apiSubscription.go b/scnserver/api/handler/apiSubscription.go index 10bab87..faa6d80 100644 --- a/scnserver/api/handler/apiSubscription.go +++ b/scnserver/api/handler/apiSubscription.go @@ -25,7 +25,7 @@ import ( // @ID api-user-subscriptions-list // @Tags API-v2 // -// @Param uid path string true "UserID" +// @Param uid path string true "UserID" // @Param selector query string true "Filter subscriptions (default: outgoing_all)" Enums(outgoing_all, outgoing_confirmed, outgoing_unconfirmed, incoming_all, incoming_confirmed, incoming_unconfirmed) // // @Success 200 {object} handler.ListUserSubscriptions.response @@ -275,7 +275,7 @@ func (h APIHandler) CancelSubscription(g *gin.Context) ginresp.HTTPResponse { // @ID api-subscriptions-create // @Tags API-v2 // -// @Param uid path string true "UserID" +// @Param uid path string true "UserID" // @Param query_data query handler.CreateSubscription.query false " " // @Param post_data body handler.CreateSubscription.body false " " // @@ -379,8 +379,8 @@ func (h APIHandler) CreateSubscription(g *gin.Context) ginresp.HTTPResponse { // @ID api-subscriptions-update // @Tags API-v2 // -// @Param uid path string true "UserID" -// @Param sid path string true "SubscriptionID" +// @Param uid path string true "UserID" +// @Param sid path string true "SubscriptionID" // @Param post_data body handler.UpdateSubscription.body false " " // // @Success 200 {object} models.SubscriptionJSON diff --git a/scnserver/api/handler/apiUser.go b/scnserver/api/handler/apiUser.go index 7f23c9a..f21b401 100644 --- a/scnserver/api/handler/apiUser.go +++ b/scnserver/api/handler/apiUser.go @@ -180,7 +180,7 @@ func (h APIHandler) GetUser(g *gin.Context) ginresp.HTTPResponse { // @ID api-user-update // @Tags API-v2 // -// @Param uid path string true "UserID" +// @Param uid path string true "UserID" // // @Param username body string false "Change the username (send an empty string to clear it)" // @Param pro_token body string false "Send a verification of premium purchase" diff --git a/scnserver/go.mod b/scnserver/go.mod index 6c1af81..698ec12 100644 --- a/scnserver/go.mod +++ b/scnserver/go.mod @@ -3,34 +3,40 @@ module blackforestbytes.com/simplecloudnotifier go 1.19 require ( - github.com/gin-gonic/gin v1.8.1 - github.com/go-playground/validator/v10 v10.10.0 - github.com/go-sql-driver/mysql v1.6.0 + github.com/gin-gonic/gin v1.9.1 + github.com/go-playground/validator/v10 v10.14.1 + github.com/go-sql-driver/mysql v1.7.1 github.com/jmoiron/sqlx v1.3.5 - github.com/mattn/go-sqlite3 v1.14.16 - github.com/rs/zerolog v1.28.0 - gogs.mikescher.com/BlackForestBytes/goext v0.0.130 - gopkg.in/loremipsum.v1 v1.1.0 + github.com/mattn/go-sqlite3 v1.14.17 + github.com/rs/zerolog v1.29.1 + gogs.mikescher.com/BlackForestBytes/goext v0.0.156 + gopkg.in/loremipsum.v1 v1.1.2 ) require ( + github.com/bytedance/sonic v1.9.1 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-playground/locales v0.14.0 // indirect - github.com/go-playground/universal-translator v0.18.0 // indirect - github.com/goccy/go-json v0.9.7 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/goccy/go-json v0.10.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/leodido/go-urn v1.2.1 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/leodido/go-urn v1.2.4 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.0.1 // indirect - github.com/ugorji/go/codec v1.2.7 // indirect - golang.org/x/crypto v0.4.0 // indirect - golang.org/x/net v0.3.0 // indirect - golang.org/x/sys v0.3.0 // indirect - golang.org/x/text v0.5.0 // indirect - google.golang.org/protobuf v1.28.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect + github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.11 // indirect + golang.org/x/arch v0.3.0 // indirect + golang.org/x/crypto v0.9.0 // indirect + golang.org/x/net v0.10.0 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/text v0.9.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/scnserver/go.sum b/scnserver/go.sum index 1d5a1c4..15e2665 100644 --- a/scnserver/go.sum +++ b/scnserver/go.sum @@ -1,24 +1,31 @@ -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= +github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= +github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= -github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= -github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= -github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= -github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= -github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0= -github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= +github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k= +github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM= -github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= +github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -29,94 +36,80 @@ github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= -github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= +github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM= +github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU= -github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= +github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= -github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY= -github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= +github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= -github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= -github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= -gogs.mikescher.com/BlackForestBytes/goext v0.0.103 h1:CkRVpRrTlq9k3mdTNGQAr4cxaXHsKdUJNjHt5Maas4k= -gogs.mikescher.com/BlackForestBytes/goext v0.0.103/go.mod h1:w8JlyUHpoOJmW5GxsiheZkFh3vn8Mp80ynSVOFLszL0= -gogs.mikescher.com/BlackForestBytes/goext v0.0.124 h1:wYP6+qNS+kd9Ht78cdzIpeXf5PM87iQppe6LS2H2W60= -gogs.mikescher.com/BlackForestBytes/goext v0.0.124/go.mod h1:w8JlyUHpoOJmW5GxsiheZkFh3vn8Mp80ynSVOFLszL0= -gogs.mikescher.com/BlackForestBytes/goext v0.0.125 h1:l4C5/CQS/IVm364oZa8MqiG62+NYBF0/jPJWsKQ3k2c= -gogs.mikescher.com/BlackForestBytes/goext v0.0.125/go.mod h1:w8JlyUHpoOJmW5GxsiheZkFh3vn8Mp80ynSVOFLszL0= -gogs.mikescher.com/BlackForestBytes/goext v0.0.126 h1:o3u0STRaPkmNBenqzvXAOPALSyRswuDwl3Y/0MVHAx4= -gogs.mikescher.com/BlackForestBytes/goext v0.0.126/go.mod h1:w8JlyUHpoOJmW5GxsiheZkFh3vn8Mp80ynSVOFLszL0= -gogs.mikescher.com/BlackForestBytes/goext v0.0.127 h1:NYrSO1kjFWL1yMh0xqIeMZ4hUJiGjILMQwvZMLy4VEg= -gogs.mikescher.com/BlackForestBytes/goext v0.0.127/go.mod h1:w8JlyUHpoOJmW5GxsiheZkFh3vn8Mp80ynSVOFLszL0= -gogs.mikescher.com/BlackForestBytes/goext v0.0.130 h1:Gc50AWtjEQK9db7Osz7EFvW/hTwXBVQSAuadsBm6Cj4= -gogs.mikescher.com/BlackForestBytes/goext v0.0.130/go.mod h1:w8JlyUHpoOJmW5GxsiheZkFh3vn8Mp80ynSVOFLszL0= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= -golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.3.0 h1:VWL6FNY2bEEmsGVKabSlHu5Irp34xmMRoqb/9lF9lxk= -golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +gogs.mikescher.com/BlackForestBytes/goext v0.0.155 h1:eFcWmq9OXk4yCw8mjuyz8+JWiUEqjeSGoWOHwO000co= +gogs.mikescher.com/BlackForestBytes/goext v0.0.155/go.mod h1:bIcO9mw2CD03pmJcBaE5YCF6etG5u73OVkUa8Alx3D0= +gogs.mikescher.com/BlackForestBytes/goext v0.0.156 h1:mRRyAkLQCGVbDfG1t+7Y3zTf1S4TNajENiRpX1KTGw8= +gogs.mikescher.com/BlackForestBytes/goext v0.0.156/go.mod h1:bIcO9mw2CD03pmJcBaE5YCF6etG5u73OVkUa8Alx3D0= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= +golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/loremipsum.v1 v1.1.0 h1:j6TAjs6Db5AMfLwTzs51Kq4Qx7dCufw/IJ0hpMbjU8U= -gopkg.in/loremipsum.v1 v1.1.0/go.mod h1:bgP3Lq/dzIvYEMrwxIwVMx/W8aQ5167rlu+UO7zGdf0= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/loremipsum.v1 v1.1.2 h1:12APklfJKuGszqZsrArW5QoQh03/W+qyCCjvnDuS6Tw= +gopkg.in/loremipsum.v1 v1.1.2/go.mod h1:TuRvzFuzuejXj+odBU6Tubp/EPUyGb9wmSvHenyP2Ts= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/scnserver/logic/application.go b/scnserver/logic/application.go index b64f344..113786c 100644 --- a/scnserver/logic/application.go +++ b/scnserver/logic/application.go @@ -242,20 +242,20 @@ func (app *Application) StartRequest(g *gin.Context, uri any, query any, body an if body != nil { if g.ContentType() == "application/json" { if err := g.ShouldBindJSON(body); err != nil { - return nil, langext.Ptr(ginresp.APIError(g, apierr.BindFailJSON, "Failed to read body", err)) - } + return nil, langext.Ptr(ginresp.APIError(g, 400, apierr.BINDFAIL_BODY_PARAM, "Failed to read body", err)) + } } else { - return nil, langext.Ptr(ginresp.APIError(g, apierr.BindFailJSON, "missing JSON body", nil)) + return nil, langext.Ptr(ginresp.APIError(g, 400, apierr.BINDFAIL_BODY_PARAM, "missing JSON body", nil)) } } if form != nil { - if g.ContentType() == "multipart/form-data" { + if g.ContentType() == "multipart/form-data" { if err := g.ShouldBindWith(form, binding.Form); err != nil { - return nil, langext.Ptr(ginresp.APIError(g, apierr.BindFailFormData, "Failed to read multipart-form", err)) - } + return nil, langext.Ptr(ginresp.APIError(g, 400, apierr.BINDFAIL_BODY_PARAM, "Failed to read multipart-form", err)) + } } else { - return nil, langext.Ptr(ginresp.APIError(g, apierr.BindFailJSON, "missing form body", nil)) + return nil, langext.Ptr(ginresp.APIError(g, 400, apierr.BINDFAIL_BODY_PARAM, "missing form body", nil)) } } diff --git a/scnserver/models/enums_gen.go b/scnserver/models/enums_gen.go index 74fb24f..21e0ad6 100644 --- a/scnserver/models/enums_gen.go +++ b/scnserver/models/enums_gen.go @@ -1,30 +1,32 @@ -// Code generated by permissions_gen.sh DO NOT EDIT. +// Code generated by enum-generate.go DO NOT EDIT. package models import "gogs.mikescher.com/BlackForestBytes/goext/langext" +const ChecksumGenerator = "4bfd61daa179e1452035a34c25c6f8170a08500bc0a7aa0e3981f95ad4b0d7d2" + type Enum interface { - Valid() bool - ValuesAny() []any - ValuesMeta() []EnumMetaValue - VarName() string + Valid() bool + ValuesAny() []any + ValuesMeta() []EnumMetaValue + VarName() string } type StringEnum interface { - Enum - String() string + Enum + String() string } type DescriptionEnum interface { - Enum - Description() string + Enum + Description() string } type EnumMetaValue struct { - VarName string `json:"varName"` - Value any `json:"value"` - Description *string `json:"description"` + VarName string `json:"varName"` + Value any `json:"value"` + Description *string `json:"description"` } // ================================ ClientType ================================ @@ -35,63 +37,63 @@ type EnumMetaValue struct { // var __ClientTypeValues = []ClientType{ - ClientTypeAndroid, - ClientTypeIOS, + ClientTypeAndroid, + ClientTypeIOS, } var __ClientTypeVarnames = map[ClientType]string{ - ClientTypeAndroid: "ClientTypeAndroid", - ClientTypeIOS: "ClientTypeIOS", + ClientTypeAndroid: "ClientTypeAndroid", + ClientTypeIOS: "ClientTypeIOS", } func (e ClientType) Valid() bool { - return langext.InArray(e, __ClientTypeValues) + return langext.InArray(e, __ClientTypeValues) } func (e ClientType) Values() []ClientType { - return __ClientTypeValues + return __ClientTypeValues } func (e ClientType) ValuesAny() []any { - return langext.ArrCastToAny(__ClientTypeValues) + return langext.ArrCastToAny(__ClientTypeValues) } func (e ClientType) ValuesMeta() []EnumMetaValue { - return []EnumMetaValue{ - EnumMetaValue{VarName: "ClientTypeAndroid", Value: ClientTypeAndroid, Description: nil}, - EnumMetaValue{VarName: "ClientTypeIOS", Value: ClientTypeIOS, Description: nil}, - } + return []EnumMetaValue{ + EnumMetaValue{VarName: "ClientTypeAndroid", Value: ClientTypeAndroid, Description: nil}, + EnumMetaValue{VarName: "ClientTypeIOS", Value: ClientTypeIOS, Description: nil}, + } } func (e ClientType) String() string { - return string(e) + return string(e) } func (e ClientType) VarName() string { - if d, ok := __ClientTypeVarnames[e]; ok { - return d - } - return "" + if d, ok := __ClientTypeVarnames[e]; ok { + return d + } + return "" } func ParseClientType(vv string) (ClientType, bool) { - for _, ev := range __ClientTypeValues { - if string(ev) == vv { - return ev, true - } - } - return "", false + for _, ev := range __ClientTypeValues { + if string(ev) == vv { + return ev, true + } + } + return "", false } func ClientTypeValues() []ClientType { - return __ClientTypeValues + return __ClientTypeValues } func ClientTypeValuesMeta() []EnumMetaValue { - return []EnumMetaValue{ - EnumMetaValue{VarName: "ClientTypeAndroid", Value: ClientTypeAndroid, Description: nil}, - EnumMetaValue{VarName: "ClientTypeIOS", Value: ClientTypeIOS, Description: nil}, - } + return []EnumMetaValue{ + EnumMetaValue{VarName: "ClientTypeAndroid", Value: ClientTypeAndroid, Description: nil}, + EnumMetaValue{VarName: "ClientTypeIOS", Value: ClientTypeIOS, Description: nil}, + } } // ================================ DeliveryStatus ================================ @@ -102,67 +104,67 @@ func ClientTypeValuesMeta() []EnumMetaValue { // var __DeliveryStatusValues = []DeliveryStatus{ - DeliveryStatusRetry, - DeliveryStatusSuccess, - DeliveryStatusFailed, + DeliveryStatusRetry, + DeliveryStatusSuccess, + DeliveryStatusFailed, } var __DeliveryStatusVarnames = map[DeliveryStatus]string{ - DeliveryStatusRetry: "DeliveryStatusRetry", - DeliveryStatusSuccess: "DeliveryStatusSuccess", - DeliveryStatusFailed: "DeliveryStatusFailed", + DeliveryStatusRetry: "DeliveryStatusRetry", + DeliveryStatusSuccess: "DeliveryStatusSuccess", + DeliveryStatusFailed: "DeliveryStatusFailed", } func (e DeliveryStatus) Valid() bool { - return langext.InArray(e, __DeliveryStatusValues) + return langext.InArray(e, __DeliveryStatusValues) } func (e DeliveryStatus) Values() []DeliveryStatus { - return __DeliveryStatusValues + return __DeliveryStatusValues } func (e DeliveryStatus) ValuesAny() []any { - return langext.ArrCastToAny(__DeliveryStatusValues) + return langext.ArrCastToAny(__DeliveryStatusValues) } func (e DeliveryStatus) ValuesMeta() []EnumMetaValue { - return []EnumMetaValue{ - EnumMetaValue{VarName: "DeliveryStatusRetry", Value: DeliveryStatusRetry, Description: nil}, - EnumMetaValue{VarName: "DeliveryStatusSuccess", Value: DeliveryStatusSuccess, Description: nil}, - EnumMetaValue{VarName: "DeliveryStatusFailed", Value: DeliveryStatusFailed, Description: nil}, - } + return []EnumMetaValue{ + EnumMetaValue{VarName: "DeliveryStatusRetry", Value: DeliveryStatusRetry, Description: nil}, + EnumMetaValue{VarName: "DeliveryStatusSuccess", Value: DeliveryStatusSuccess, Description: nil}, + EnumMetaValue{VarName: "DeliveryStatusFailed", Value: DeliveryStatusFailed, Description: nil}, + } } func (e DeliveryStatus) String() string { - return string(e) + return string(e) } func (e DeliveryStatus) VarName() string { - if d, ok := __DeliveryStatusVarnames[e]; ok { - return d - } - return "" + if d, ok := __DeliveryStatusVarnames[e]; ok { + return d + } + return "" } func ParseDeliveryStatus(vv string) (DeliveryStatus, bool) { - for _, ev := range __DeliveryStatusValues { - if string(ev) == vv { - return ev, true - } - } - return "", false + for _, ev := range __DeliveryStatusValues { + if string(ev) == vv { + return ev, true + } + } + return "", false } func DeliveryStatusValues() []DeliveryStatus { - return __DeliveryStatusValues + return __DeliveryStatusValues } func DeliveryStatusValuesMeta() []EnumMetaValue { - return []EnumMetaValue{ - EnumMetaValue{VarName: "DeliveryStatusRetry", Value: DeliveryStatusRetry, Description: nil}, - EnumMetaValue{VarName: "DeliveryStatusSuccess", Value: DeliveryStatusSuccess, Description: nil}, - EnumMetaValue{VarName: "DeliveryStatusFailed", Value: DeliveryStatusFailed, Description: nil}, - } + return []EnumMetaValue{ + EnumMetaValue{VarName: "DeliveryStatusRetry", Value: DeliveryStatusRetry, Description: nil}, + EnumMetaValue{VarName: "DeliveryStatusSuccess", Value: DeliveryStatusSuccess, Description: nil}, + EnumMetaValue{VarName: "DeliveryStatusFailed", Value: DeliveryStatusFailed, Description: nil}, + } } // ================================ TokenPerm ================================ @@ -173,84 +175,83 @@ func DeliveryStatusValuesMeta() []EnumMetaValue { // var __TokenPermValues = []TokenPerm{ - PermAdmin, - PermChannelRead, - PermChannelSend, - PermUserRead, + PermAdmin, + PermChannelRead, + PermChannelSend, + PermUserRead, } var __TokenPermDescriptions = map[TokenPerm]string{ - PermAdmin: "Edit userdata (+ includes all other permissions)", - PermChannelRead: "Read messages", - PermChannelSend: "Send messages", - PermUserRead: "Read userdata", + PermAdmin: "Edit userdata (+ includes all other permissions)", + PermChannelRead: "Read messages", + PermChannelSend: "Send messages", + PermUserRead: "Read userdata", } var __TokenPermVarnames = map[TokenPerm]string{ - PermAdmin: "PermAdmin", - PermChannelRead: "PermChannelRead", - PermChannelSend: "PermChannelSend", - PermUserRead: "PermUserRead", + PermAdmin: "PermAdmin", + PermChannelRead: "PermChannelRead", + PermChannelSend: "PermChannelSend", + PermUserRead: "PermUserRead", } func (e TokenPerm) Valid() bool { - return langext.InArray(e, __TokenPermValues) + return langext.InArray(e, __TokenPermValues) } func (e TokenPerm) Values() []TokenPerm { - return __TokenPermValues + return __TokenPermValues } func (e TokenPerm) ValuesAny() []any { - return langext.ArrCastToAny(__TokenPermValues) + return langext.ArrCastToAny(__TokenPermValues) } func (e TokenPerm) ValuesMeta() []EnumMetaValue { - return []EnumMetaValue{ - EnumMetaValue{VarName: "PermAdmin", Value: PermAdmin, Description: langext.Ptr("Edit userdata (+ includes all other permissions)")}, - EnumMetaValue{VarName: "PermChannelRead", Value: PermChannelRead, Description: langext.Ptr("Read messages")}, - EnumMetaValue{VarName: "PermChannelSend", Value: PermChannelSend, Description: langext.Ptr("Send messages")}, - EnumMetaValue{VarName: "PermUserRead", Value: PermUserRead, Description: langext.Ptr("Read userdata")}, - } + return []EnumMetaValue{ + EnumMetaValue{VarName: "PermAdmin", Value: PermAdmin, Description: langext.Ptr("Edit userdata (+ includes all other permissions)")}, + EnumMetaValue{VarName: "PermChannelRead", Value: PermChannelRead, Description: langext.Ptr("Read messages")}, + EnumMetaValue{VarName: "PermChannelSend", Value: PermChannelSend, Description: langext.Ptr("Send messages")}, + EnumMetaValue{VarName: "PermUserRead", Value: PermUserRead, Description: langext.Ptr("Read userdata")}, + } } func (e TokenPerm) String() string { - return string(e) + return string(e) } func (e TokenPerm) Description() string { - if d, ok := __TokenPermDescriptions[e]; ok { - return d - } - return "" + if d, ok := __TokenPermDescriptions[e]; ok { + return d + } + return "" } func (e TokenPerm) VarName() string { - if d, ok := __TokenPermVarnames[e]; ok { - return d - } - return "" + if d, ok := __TokenPermVarnames[e]; ok { + return d + } + return "" } func ParseTokenPerm(vv string) (TokenPerm, bool) { - for _, ev := range __TokenPermValues { - if string(ev) == vv { - return ev, true - } - } - return "", false + for _, ev := range __TokenPermValues { + if string(ev) == vv { + return ev, true + } + } + return "", false } func TokenPermValues() []TokenPerm { - return __TokenPermValues + return __TokenPermValues } func TokenPermValuesMeta() []EnumMetaValue { - return []EnumMetaValue{ - EnumMetaValue{VarName: "PermAdmin", Value: PermAdmin, Description: langext.Ptr("Edit userdata (+ includes all other permissions)")}, - EnumMetaValue{VarName: "PermChannelRead", Value: PermChannelRead, Description: langext.Ptr("Read messages")}, - EnumMetaValue{VarName: "PermChannelSend", Value: PermChannelSend, Description: langext.Ptr("Send messages")}, - EnumMetaValue{VarName: "PermUserRead", Value: PermUserRead, Description: langext.Ptr("Read userdata")}, - } + return []EnumMetaValue{ + EnumMetaValue{VarName: "PermAdmin", Value: PermAdmin, Description: langext.Ptr("Edit userdata (+ includes all other permissions)")}, + EnumMetaValue{VarName: "PermChannelRead", Value: PermChannelRead, Description: langext.Ptr("Read messages")}, + EnumMetaValue{VarName: "PermChannelSend", Value: PermChannelSend, Description: langext.Ptr("Send messages")}, + EnumMetaValue{VarName: "PermUserRead", Value: PermUserRead, Description: langext.Ptr("Read userdata")}, + } } - diff --git a/scnserver/swagger/swagger.json b/scnserver/swagger/swagger.json index 8a98a33..8faadf1 100644 --- a/scnserver/swagger/swagger.json +++ b/scnserver/swagger/swagger.json @@ -1154,7 +1154,7 @@ "operationId": "api-user-update", "parameters": [ { - "type": "integer", + "type": "string", "description": "UserID", "name": "uid", "in": "path", @@ -1221,7 +1221,7 @@ "operationId": "api-channels-list", "parameters": [ { - "type": "integer", + "type": "string", "description": "UserID", "name": "uid", "in": "path", @@ -1276,7 +1276,7 @@ "operationId": "api-channels-create", "parameters": [ { - "type": "integer", + "type": "string", "description": "UserID", "name": "uid", "in": "path", @@ -1389,14 +1389,14 @@ "operationId": "api-channels-update", "parameters": [ { - "type": "integer", + "type": "string", "description": "UserID", "name": "uid", "in": "path", "required": true }, { - "type": "integer", + "type": "string", "description": "ChannelID", "name": "cid", "in": "path", @@ -1491,14 +1491,14 @@ "in": "query" }, { - "type": "integer", + "type": "string", "description": "UserID", "name": "uid", "in": "path", "required": true }, { - "type": "integer", + "type": "string", "description": "ChannelID", "name": "cid", "in": "path", @@ -1647,7 +1647,7 @@ "operationId": "api-clients-create", "parameters": [ { - "type": "integer", + "type": "string", "description": "UserID", "name": "uid", "in": "path", @@ -1800,6 +1800,78 @@ } } } + }, + "patch": { + "description": "The body-values are optional, only send the ones you want to update", + "tags": [ + "API-v2" + ], + "summary": "(Partially) update a client", + "operationId": "api-client-update", + "parameters": [ + { + "type": "string", + "description": "UserID", + "name": "uid", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "ClientID", + "name": "cid", + "in": "path", + "required": true + }, + { + "description": "Change the clientname (send an empty string to clear it)", + "name": "clientname", + "in": "body", + "schema": { + "type": "string" + } + }, + { + "description": "Send a verification of premium purchase", + "name": "pro_token", + "in": "body", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.ClientJSON" + } + }, + "400": { + "description": "supplied values/parameters cannot be parsed / are invalid", + "schema": { + "$ref": "#/definitions/ginresp.apiError" + } + }, + "401": { + "description": "client is not authorized / has missing permissions", + "schema": { + "$ref": "#/definitions/ginresp.apiError" + } + }, + "404": { + "description": "client not found", + "schema": { + "$ref": "#/definitions/ginresp.apiError" + } + }, + "500": { + "description": "internal server error", + "schema": { + "$ref": "#/definitions/ginresp.apiError" + } + } + } } }, "/api/v2/users/{uid}/keys": { @@ -1860,7 +1932,7 @@ "operationId": "api-tokenkeys-create", "parameters": [ { - "type": "integer", + "type": "string", "description": "UserID", "name": "uid", "in": "path", @@ -2030,14 +2102,14 @@ "operationId": "api-tokenkeys-update", "parameters": [ { - "type": "integer", + "type": "string", "description": "UserID", "name": "uid", "in": "path", "required": true }, { - "type": "integer", + "type": "string", "description": "TokenKeyID", "name": "kid", "in": "path", @@ -2096,7 +2168,7 @@ "operationId": "api-user-subscriptions-list", "parameters": [ { - "type": "integer", + "type": "string", "description": "UserID", "name": "uid", "in": "path", @@ -2154,7 +2226,7 @@ "operationId": "api-subscriptions-create", "parameters": [ { - "type": "integer", + "type": "string", "description": "UserID", "name": "uid", "in": "path", @@ -2321,14 +2393,14 @@ "operationId": "api-subscriptions-update", "parameters": [ { - "type": "integer", + "type": "string", "description": "UserID", "name": "uid", "in": "path", "required": true }, { - "type": "integer", + "type": "string", "description": "SubscriptionID", "name": "sid", "in": "path", diff --git a/scnserver/swagger/swagger.yaml b/scnserver/swagger/swagger.yaml index 247d7d3..0eb5337 100644 --- a/scnserver/swagger/swagger.yaml +++ b/scnserver/swagger/swagger.yaml @@ -1471,7 +1471,7 @@ paths: in: path name: uid required: true - type: integer + type: string - description: Change the username (send an empty string to clear it) in: body name: username @@ -1521,7 +1521,7 @@ paths: in: path name: uid required: true - type: integer + type: string - description: 'Filter channels (default: owned)' enum: - owned @@ -1559,7 +1559,7 @@ paths: in: path name: uid required: true - type: integer + type: string - description: ' ' in: body name: post_body @@ -1634,12 +1634,12 @@ paths: in: path name: uid required: true - type: integer + type: string - description: ChannelID in: path name: cid required: true - type: integer + type: string - description: Send `true` to create a new subscribe_key in: body name: subscribe_key @@ -1705,12 +1705,12 @@ paths: in: path name: uid required: true - type: integer + type: string - description: ChannelID in: path name: cid required: true - type: integer + type: string responses: "200": description: OK @@ -1809,7 +1809,7 @@ paths: in: path name: uid required: true - type: integer + type: string - description: ' ' in: body name: post_body @@ -1910,6 +1910,54 @@ paths: summary: Get a single client tags: - API-v2 + patch: + description: The body-values are optional, only send the ones you want to update + operationId: api-client-update + parameters: + - description: UserID + in: path + name: uid + required: true + type: string + - description: ClientID + in: path + name: cid + required: true + type: string + - description: Change the clientname (send an empty string to clear it) + in: body + name: clientname + schema: + type: string + - description: Send a verification of premium purchase + in: body + name: pro_token + schema: + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/models.ClientJSON' + "400": + description: supplied values/parameters cannot be parsed / are invalid + schema: + $ref: '#/definitions/ginresp.apiError' + "401": + description: client is not authorized / has missing permissions + schema: + $ref: '#/definitions/ginresp.apiError' + "404": + description: client not found + schema: + $ref: '#/definitions/ginresp.apiError' + "500": + description: internal server error + schema: + $ref: '#/definitions/ginresp.apiError' + summary: (Partially) update a client + tags: + - API-v2 /api/v2/users/{uid}/keys: get: description: The request must be done with an ADMIN key, the returned keys are @@ -1952,7 +2000,7 @@ paths: in: path name: uid required: true - type: integer + type: string - description: ' ' in: body name: post_body @@ -2067,12 +2115,12 @@ paths: in: path name: uid required: true - type: integer + type: string - description: TokenKeyID in: path name: kid required: true - type: integer + type: string - description: ' ' in: body name: post_body @@ -2118,7 +2166,7 @@ paths: in: path name: uid required: true - type: integer + type: string - description: 'Filter subscriptions (default: outgoing_all)' enum: - outgoing_all @@ -2160,7 +2208,7 @@ paths: in: path name: uid required: true - type: integer + type: string - in: query name: chan_subscribe_key type: string @@ -2271,12 +2319,12 @@ paths: in: path name: uid required: true - type: integer + type: string - description: SubscriptionID in: path name: sid required: true - type: integer + type: string - description: ' ' in: body name: post_data