delete verified user
parent
6eba9fe1ef
commit
534694a220
14
main.go
14
main.go
|
@ -1,3 +1,17 @@
|
||||||
|
// Package classification JNX Telegram Bot Manager API Documentation.
|
||||||
|
//
|
||||||
|
// Schemes: https
|
||||||
|
// Host: jannex
|
||||||
|
// BasePath: /v1
|
||||||
|
// Version: 1.0.0
|
||||||
|
//
|
||||||
|
// Consumes:
|
||||||
|
// - application/json
|
||||||
|
//
|
||||||
|
// Produces:
|
||||||
|
// - application/json
|
||||||
|
//
|
||||||
|
// swagger:meta
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -4,5 +4,5 @@ package structs
|
||||||
type NotificationBody struct {
|
type NotificationBody struct {
|
||||||
UserIds []string
|
UserIds []string
|
||||||
Type uint8
|
Type uint8
|
||||||
Message string
|
Title string
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,20 @@
|
||||||
{
|
{
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"schemes": [
|
||||||
|
"https"
|
||||||
|
],
|
||||||
"swagger": "2.0",
|
"swagger": "2.0",
|
||||||
|
"info": {
|
||||||
|
"title": "JNX Telegram Bot Manager API Documentation.",
|
||||||
|
"version": "1.0.0"
|
||||||
|
},
|
||||||
|
"host": "jannex",
|
||||||
|
"basePath": "/v1",
|
||||||
"paths": {
|
"paths": {
|
||||||
"/v1/notification": {
|
"/v1/notification": {
|
||||||
"post": {
|
"post": {
|
||||||
|
@ -35,6 +50,41 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/v1/status/{userId}": {
|
||||||
|
"get": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"status"
|
||||||
|
],
|
||||||
|
"summary": "Check if user is verified",
|
||||||
|
"operationId": "userVerified",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "User ID",
|
||||||
|
"name": "userId",
|
||||||
|
"in": "params",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/StatusResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad request"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/v1/verifycode/{userId}": {
|
"/v1/verifycode/{userId}": {
|
||||||
"get": {
|
"get": {
|
||||||
"consumes": [
|
"consumes": [
|
||||||
|
@ -71,6 +121,39 @@
|
||||||
"description": "Internal server error"
|
"description": "Internal server error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"verifycode"
|
||||||
|
],
|
||||||
|
"summary": "Delete verified user",
|
||||||
|
"operationId": "deleteVerifiedUser",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "User ID",
|
||||||
|
"name": "userId",
|
||||||
|
"in": "params",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK"
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad request"
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal server error"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -94,6 +177,15 @@
|
||||||
},
|
},
|
||||||
"x-go-package": "jannex/telegram-bot-manager/modules/structs"
|
"x-go-package": "jannex/telegram-bot-manager/modules/structs"
|
||||||
},
|
},
|
||||||
|
"StatusResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"Status": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-go-package": "jannex/telegram-bot-manager/modules/structs"
|
||||||
|
},
|
||||||
"VerifyCodeResponse": {
|
"VerifyCodeResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -44,7 +44,7 @@ func SendNotification(c *fiber.Ctx) error {
|
||||||
// get all verified users by body userIds
|
// get all verified users by body userIds
|
||||||
database.DB.Where("user_id IN ?", body.UserIds).Find(&foundVerifiedUsers)
|
database.DB.Where("user_id IN ?", body.UserIds).Find(&foundVerifiedUsers)
|
||||||
|
|
||||||
formattedMessage := utils.GetNotificationIconByType(body.Type) + " " + body.Message
|
formattedMessage := utils.GetNotificationIconByType(body.Type) + " " + body.Title
|
||||||
|
|
||||||
// send message to all verified users
|
// send message to all verified users
|
||||||
for _, user := range foundVerifiedUsers {
|
for _, user := range foundVerifiedUsers {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package verifycode
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"jannex/telegram-bot-manager/modules/cache"
|
"jannex/telegram-bot-manager/modules/cache"
|
||||||
|
"jannex/telegram-bot-manager/modules/database"
|
||||||
"jannex/telegram-bot-manager/modules/logger"
|
"jannex/telegram-bot-manager/modules/logger"
|
||||||
"jannex/telegram-bot-manager/modules/structs"
|
"jannex/telegram-bot-manager/modules/structs"
|
||||||
"jannex/telegram-bot-manager/modules/utils"
|
"jannex/telegram-bot-manager/modules/utils"
|
||||||
|
@ -58,3 +59,38 @@ func GetVerifyCode(c *fiber.Ctx) error {
|
||||||
|
|
||||||
return c.JSON(structs.VerifyCodeResponse{Code: code})
|
return c.JSON(structs.VerifyCodeResponse{Code: code})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeleteVerifiedUser(c *fiber.Ctx) error {
|
||||||
|
// swagger:operation DELETE /v1/verifycode/{userId} verifycode deleteVerifiedUser
|
||||||
|
// ---
|
||||||
|
// summary: Delete verified user
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: userId
|
||||||
|
// in: params
|
||||||
|
// description: User ID
|
||||||
|
// required: true
|
||||||
|
// type: string
|
||||||
|
// responses:
|
||||||
|
// '200':
|
||||||
|
// description: OK
|
||||||
|
// '400':
|
||||||
|
// description: Bad request
|
||||||
|
// '500':
|
||||||
|
// description: Internal server error
|
||||||
|
|
||||||
|
var params structs.UserIdParam
|
||||||
|
|
||||||
|
if err := rsutils.ParamsParserHelper(c, ¶ms); err != nil {
|
||||||
|
return c.SendStatus(fiber.StatusBadRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
database.DB.Where("user_id = ?", params.UserId).Delete(&structs.VerifiedUser{})
|
||||||
|
|
||||||
|
logger.AddSystemLog(rslogger.LogTypeInfo, "Deleted verified user %s", params.UserId)
|
||||||
|
|
||||||
|
return c.SendStatus(fiber.StatusOK)
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ func SetupRoutes(app *fiber.App) {
|
||||||
|
|
||||||
vc := v1.Group("/verifycode")
|
vc := v1.Group("/verifycode")
|
||||||
vc.Get("/:userId", verifycode.GetVerifyCode)
|
vc.Get("/:userId", verifycode.GetVerifyCode)
|
||||||
|
vc.Delete("/:userId", verifycode.DeleteVerifiedUser)
|
||||||
|
|
||||||
n := v1.Group("/notification")
|
n := v1.Group("/notification")
|
||||||
n.Post("/", notification.SendNotification)
|
n.Post("/", notification.SendNotification)
|
||||||
|
|
Loading…
Reference in New Issue