status
parent
6e09cea56c
commit
6eba9fe1ef
|
@ -0,0 +1,6 @@
|
||||||
|
package structs
|
||||||
|
|
||||||
|
// swagger:model StatusResponse
|
||||||
|
type StatusResponse struct {
|
||||||
|
Status bool
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ type VerifiedUser struct {
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type VerifyCodeParams struct {
|
type UserIdParam struct {
|
||||||
UserId string
|
UserId string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 243 KiB |
|
@ -0,0 +1,48 @@
|
||||||
|
package status
|
||||||
|
|
||||||
|
import (
|
||||||
|
"jannex/telegram-bot-manager/modules/database"
|
||||||
|
"jannex/telegram-bot-manager/modules/structs"
|
||||||
|
|
||||||
|
"git.ex.umbach.dev/Alex/roese-utils/rsutils"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func UserVerified(c *fiber.Ctx) error {
|
||||||
|
// swagger:operation GET /v1/status/{userId} status userVerified
|
||||||
|
// ---
|
||||||
|
// summary: Check if user is verified
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: userId
|
||||||
|
// in: params
|
||||||
|
// description: User ID
|
||||||
|
// required: true
|
||||||
|
// type: string
|
||||||
|
// responses:
|
||||||
|
// '200':
|
||||||
|
// description: OK
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/StatusResponse"
|
||||||
|
// '400':
|
||||||
|
// description: Bad request
|
||||||
|
|
||||||
|
var params structs.UserIdParam
|
||||||
|
|
||||||
|
if err := rsutils.ParamsParserHelper(c, ¶ms); err != nil {
|
||||||
|
return c.SendStatus(fiber.StatusBadRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
var foundVerifiedUser structs.VerifiedUser
|
||||||
|
|
||||||
|
// get verified user by userId
|
||||||
|
database.DB.Where("user_id = ?", params.UserId).First(&foundVerifiedUser)
|
||||||
|
|
||||||
|
log.Info().Msgf("Found verified user: %v", foundVerifiedUser)
|
||||||
|
|
||||||
|
return c.JSON(structs.StatusResponse{Status: foundVerifiedUser.UserId != ""})
|
||||||
|
}
|
|
@ -36,7 +36,7 @@ func GetVerifyCode(c *fiber.Ctx) error {
|
||||||
// '500':
|
// '500':
|
||||||
// description: Internal server error
|
// description: Internal server error
|
||||||
|
|
||||||
var params structs.VerifyCodeParams
|
var params structs.UserIdParam
|
||||||
|
|
||||||
if err := rsutils.ParamsParserHelper(c, ¶ms); err != nil {
|
if err := rsutils.ParamsParserHelper(c, ¶ms); err != nil {
|
||||||
return c.SendStatus(fiber.StatusBadRequest)
|
return c.SendStatus(fiber.StatusBadRequest)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"jannex/telegram-bot-manager/routers/api/v1/notification"
|
"jannex/telegram-bot-manager/routers/api/v1/notification"
|
||||||
|
"jannex/telegram-bot-manager/routers/api/v1/status"
|
||||||
"jannex/telegram-bot-manager/routers/api/v1/verifycode"
|
"jannex/telegram-bot-manager/routers/api/v1/verifycode"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
@ -16,5 +17,8 @@ func SetupRoutes(app *fiber.App) {
|
||||||
n := v1.Group("/notification")
|
n := v1.Group("/notification")
|
||||||
n.Post("/", notification.SendNotification)
|
n.Post("/", notification.SendNotification)
|
||||||
|
|
||||||
|
s := v1.Group("/status")
|
||||||
|
s.Get("/:userId", status.UserVerified)
|
||||||
|
|
||||||
app.Static("/", "./public/")
|
app.Static("/", "./public/")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue