Don't use abort
This commit is contained in:
parent
2cfa5e9750
commit
500b09516a
@ -59,7 +59,7 @@ func MultiPanelCreate(ctx *gin.Context) {
|
|||||||
// get bot context
|
// get bot context
|
||||||
botContext, err := botcontext.ContextForGuild(guildId)
|
botContext, err := botcontext.ContextForGuild(guildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
|
@ -45,7 +45,7 @@ func MultiPanelResend(ctx *gin.Context) {
|
|||||||
// get bot context
|
// get bot context
|
||||||
botContext, err := botcontext.ContextForGuild(guildId)
|
botContext, err := botcontext.ContextForGuild(guildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, utils.ErrorJson(err))
|
ctx.JSON(500, utils.ErrorJson(err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ func MultiPanelUpdate(ctx *gin.Context) {
|
|||||||
// get bot context
|
// get bot context
|
||||||
botContext, err := botcontext.ContextForGuild(guildId)
|
botContext, err := botcontext.ContextForGuild(guildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, utils.ErrorJson(err))
|
ctx.JSON(500, utils.ErrorJson(err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ func PremiumHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
botContext, err := botcontext.ContextForGuild(guildId)
|
botContext, err := botcontext.ContextForGuild(guildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
|
@ -19,7 +19,7 @@ func CloseTicket(ctx *gin.Context) {
|
|||||||
|
|
||||||
ticketId, err := strconv.Atoi(ctx.Param("ticketId"))
|
ticketId, err := strconv.Atoi(ctx.Param("ticketId"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(400, gin.H{
|
ctx.JSON(400, gin.H{
|
||||||
"success": true,
|
"success": true,
|
||||||
"error": "Invalid ticket ID",
|
"error": "Invalid ticket ID",
|
||||||
})
|
})
|
||||||
@ -28,7 +28,7 @@ func CloseTicket(ctx *gin.Context) {
|
|||||||
|
|
||||||
var body closeBody
|
var body closeBody
|
||||||
if err := ctx.BindJSON(&body); err != nil {
|
if err := ctx.BindJSON(&body); err != nil {
|
||||||
ctx.AbortWithStatusJSON(400, gin.H{
|
ctx.JSON(400, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "Missing reason",
|
"error": "Missing reason",
|
||||||
})
|
})
|
||||||
@ -38,7 +38,7 @@ func CloseTicket(ctx *gin.Context) {
|
|||||||
// Get the ticket struct
|
// Get the ticket struct
|
||||||
ticket, err := database.Client.Tickets.Get(ticketId, guildId)
|
ticket, err := database.Client.Tickets.Get(ticketId, guildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": true,
|
"success": true,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
@ -47,7 +47,7 @@ func CloseTicket(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the ticket exists
|
// Verify the ticket exists
|
||||||
if ticket.UserId == 0 {
|
if ticket.UserId == 0 {
|
||||||
ctx.AbortWithStatusJSON(404, gin.H{
|
ctx.JSON(404, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "Ticket does not exist",
|
"error": "Ticket does not exist",
|
||||||
})
|
})
|
||||||
|
@ -21,7 +21,7 @@ func GetTicket(ctx *gin.Context) {
|
|||||||
|
|
||||||
botContext, err := botcontext.ContextForGuild(guildId)
|
botContext, err := botcontext.ContextForGuild(guildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
@ -30,7 +30,7 @@ func GetTicket(ctx *gin.Context) {
|
|||||||
|
|
||||||
ticketId, err := strconv.Atoi(ctx.Param("ticketId"))
|
ticketId, err := strconv.Atoi(ctx.Param("ticketId"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(400, gin.H{
|
ctx.JSON(400, gin.H{
|
||||||
"success": true,
|
"success": true,
|
||||||
"error": "Invalid ticket ID",
|
"error": "Invalid ticket ID",
|
||||||
})
|
})
|
||||||
@ -40,7 +40,7 @@ func GetTicket(ctx *gin.Context) {
|
|||||||
// Get the ticket struct
|
// Get the ticket struct
|
||||||
ticket, err := database.Client.Tickets.Get(ticketId, guildId)
|
ticket, err := database.Client.Tickets.Get(ticketId, guildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": true,
|
"success": true,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
@ -48,7 +48,7 @@ func GetTicket(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ticket.GuildId != guildId {
|
if ticket.GuildId != guildId {
|
||||||
ctx.AbortWithStatusJSON(403, gin.H{
|
ctx.JSON(403, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "Guild ID doesn't match",
|
"error": "Guild ID doesn't match",
|
||||||
})
|
})
|
||||||
@ -56,7 +56,7 @@ func GetTicket(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !ticket.Open {
|
if !ticket.Open {
|
||||||
ctx.AbortWithStatusJSON(404, gin.H{
|
ctx.JSON(404, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "Ticket does not exist",
|
"error": "Ticket does not exist",
|
||||||
})
|
})
|
||||||
|
@ -25,7 +25,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
|
|
||||||
botContext, err := botcontext.ContextForGuild(guildId)
|
botContext, err := botcontext.ContextForGuild(guildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
@ -35,7 +35,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
// Get ticket ID
|
// Get ticket ID
|
||||||
ticketId, err := strconv.Atoi(ctx.Param("ticketId"))
|
ticketId, err := strconv.Atoi(ctx.Param("ticketId"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(400, gin.H{
|
ctx.JSON(400, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "Invalid ticket ID",
|
"error": "Invalid ticket ID",
|
||||||
})
|
})
|
||||||
@ -44,7 +44,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
|
|
||||||
var body sendMessageBody
|
var body sendMessageBody
|
||||||
if err := ctx.BindJSON(&body); err != nil {
|
if err := ctx.BindJSON(&body); err != nil {
|
||||||
ctx.AbortWithStatusJSON(400, gin.H{
|
ctx.JSON(400, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "Message is missing",
|
"error": "Message is missing",
|
||||||
})
|
})
|
||||||
@ -67,7 +67,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if premiumTier == premium.None {
|
if premiumTier == premium.None {
|
||||||
ctx.AbortWithStatusJSON(402, gin.H{
|
ctx.JSON(402, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "Guild is not premium",
|
"error": "Guild is not premium",
|
||||||
})
|
})
|
||||||
@ -79,7 +79,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the ticket exists
|
// Verify the ticket exists
|
||||||
if ticket.UserId == 0 {
|
if ticket.UserId == 0 {
|
||||||
ctx.AbortWithStatusJSON(404, gin.H{
|
ctx.JSON(404, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "Ticket not found",
|
"error": "Ticket not found",
|
||||||
})
|
})
|
||||||
@ -88,7 +88,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permission to send to this guild
|
// Verify the user has permission to send to this guild
|
||||||
if ticket.GuildId != guildId {
|
if ticket.GuildId != guildId {
|
||||||
ctx.AbortWithStatusJSON(403, gin.H{
|
ctx.JSON(403, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "Guild ID doesn't match",
|
"error": "Guild ID doesn't match",
|
||||||
})
|
})
|
||||||
@ -104,7 +104,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
// Preferably send via a webhook
|
// Preferably send via a webhook
|
||||||
webhook, err := database.Client.Webhooks.Get(guildId, ticketId)
|
webhook, err := database.Client.Webhooks.Get(guildId, ticketId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
@ -139,7 +139,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ticket.ChannelId == nil {
|
if ticket.ChannelId == nil {
|
||||||
ctx.AbortWithStatusJSON(404, gin.H{
|
ctx.JSON(404, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "Ticket channel ID is nil",
|
"error": "Ticket channel ID is nil",
|
||||||
})
|
})
|
||||||
@ -147,7 +147,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err = rest.CreateMessage(botContext.Token, botContext.RateLimiter, *ticket.ChannelId, rest.CreateMessageData{Content: body.Message}); err != nil {
|
if _, err = rest.CreateMessage(botContext.Token, botContext.RateLimiter, *ticket.ChannelId, rest.CreateMessageData{Content: body.Message}); err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
|
@ -23,7 +23,7 @@ func GetTranscriptHandler(ctx *gin.Context) {
|
|||||||
// get ticket object
|
// get ticket object
|
||||||
ticket, err := dbclient.Client.Tickets.Get(ticketId, guildId)
|
ticket, err := dbclient.Client.Tickets.Get(ticketId, guildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
|
@ -42,7 +42,7 @@ func ListTranscripts(ctx *gin.Context) {
|
|||||||
|
|
||||||
botContext, err := botcontext.ContextForGuild(guildId)
|
botContext, err := botcontext.ContextForGuild(guildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
|
@ -24,7 +24,7 @@ func GetTranscriptRenderHandler(ctx *gin.Context) {
|
|||||||
// get ticket object
|
// get ticket object
|
||||||
ticket, err := dbclient.Client.Tickets.Get(ticketId, guildId)
|
ticket, err := dbclient.Client.Tickets.Get(ticketId, guildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
|
@ -165,7 +165,7 @@ func WebChatWs(ctx *gin.Context) {
|
|||||||
|
|
||||||
botContext, err := botcontext.ContextForGuild(authData.GuildId)
|
botContext, err := botcontext.ContextForGuild(authData.GuildId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.JSON(500, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user