Fix closing

This commit is contained in:
rxdn 2021-02-19 21:10:28 +00:00
parent 135e83553d
commit f13dcb6a13

View File

@ -3,6 +3,8 @@ package api
import ( import (
"github.com/TicketsBot/GoPanel/database" "github.com/TicketsBot/GoPanel/database"
"github.com/TicketsBot/GoPanel/messagequeue" "github.com/TicketsBot/GoPanel/messagequeue"
"github.com/TicketsBot/GoPanel/utils"
"github.com/TicketsBot/common/closerelay"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"strconv" "strconv"
) )
@ -24,8 +26,8 @@ func CloseTicket(ctx *gin.Context) {
return return
} }
var data closeBody var body closeBody
if err := ctx.BindJSON(&data); err != nil { if err := ctx.BindJSON(&body); err != nil {
ctx.AbortWithStatusJSON(400, gin.H{ ctx.AbortWithStatusJSON(400, gin.H{
"success": true, "success": true,
"error": "Missing reason", "error": "Missing reason",
@ -60,9 +62,17 @@ func CloseTicket(ctx *gin.Context) {
return return
} }
go messagequeue.Client.PublishTicketClose(guildId, ticket.Id, userId, data.Reason) data := closerelay.TicketClose{
GuildId: guildId,
ctx.JSON(200, gin.H{ TicketId: ticket.Id,
"success": true, UserId: userId,
}) Reason: body.Reason,
}
if err := closerelay.Publish(messagequeue.Client.Client, data); err != nil {
ctx.JSON(500, utils.ErrorJson(err))
return
}
ctx.JSON(200, utils.SuccessResponse)
} }