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"
)

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, &params); 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)

	return c.JSON(structs.StatusResponse{Status: foundVerifiedUser.UserId != ""})
}
