Bump DB + Update messages
This commit is contained in:
parent
6aa8e947fc
commit
55e35dd327
@ -29,12 +29,12 @@ func MultiPanelDelete(ctx *gin.Context) {
|
|||||||
|
|
||||||
panel, ok, err := dbclient.Client.MultiPanels.Get(multiPanelId)
|
panel, ok, err := dbclient.Client.MultiPanels.Get(multiPanelId)
|
||||||
if !ok {
|
if !ok {
|
||||||
ctx.JSON(404, utils.ErrorJson(errors.New("No panel with matching ID found")))
|
ctx.JSON(404, utils.ErrorStr("No panel with matching ID found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if panel.GuildId != guildId {
|
if panel.GuildId != guildId {
|
||||||
ctx.JSON(403, utils.ErrorJson(errors.New("Guild ID doesn't match")))
|
ctx.JSON(403, utils.ErrorStr("Guild ID doesn't match"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,13 +32,13 @@ func MultiPanelResend(ctx *gin.Context) {
|
|||||||
|
|
||||||
// check panel exists
|
// check panel exists
|
||||||
if !ok {
|
if !ok {
|
||||||
ctx.JSON(404, utils.ErrorJson(errors.New("No panel with the provided ID found")))
|
ctx.JSON(404, utils.ErrorStr("No panel with the provided ID found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// check panel is in the same guild
|
// check panel is in the same guild
|
||||||
if guildId != multiPanel.GuildId {
|
if guildId != multiPanel.GuildId {
|
||||||
ctx.JSON(403, utils.ErrorJson(errors.New("Guild ID doesn't match")))
|
ctx.JSON(403, utils.ErrorStr("Guild ID doesn't match"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,11 @@ func DeletePanel(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if panel.PanelId == 0 {
|
||||||
|
ctx.JSON(404, utils.ErrorStr("Panel not found"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// verify panel belongs to guild
|
// verify panel belongs to guild
|
||||||
if panel.GuildId != guildId {
|
if panel.GuildId != guildId {
|
||||||
ctx.JSON(403, utils.ErrorStr("Guild ID doesn't match"))
|
ctx.JSON(403, utils.ErrorStr("Guild ID doesn't match"))
|
||||||
|
@ -18,29 +18,31 @@ func ResendPanel(ctx *gin.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
|
||||||
}
|
}
|
||||||
|
|
||||||
panelId, err := strconv.Atoi(ctx.Param("panelid"))
|
panelId, err := strconv.Atoi(ctx.Param("panelid"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(400, utils.ErrorJson(err))
|
ctx.JSON(400, utils.ErrorJson(err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// get existing
|
// get existing
|
||||||
panel, err := dbclient.Client.Panel.GetById(panelId)
|
panel, err := dbclient.Client.Panel.GetById(panelId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, utils.ErrorJson(err))
|
ctx.JSON(500, utils.ErrorJson(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if panel.PanelId == 0 {
|
||||||
|
ctx.JSON(404, utils.ErrorStr("Panel not found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// check guild ID matches
|
// check guild ID matches
|
||||||
if panel.GuildId != guildId {
|
if panel.GuildId != guildId {
|
||||||
ctx.AbortWithStatusJSON(400, gin.H{
|
ctx.JSON(403, utils.ErrorStr("Guild ID doesn't match"))
|
||||||
"success": false,
|
|
||||||
"error": "Guild ID does not match",
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +75,7 @@ func ResendPanel(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err = dbclient.Client.Panel.UpdateMessageId(panel.PanelId, msgId); err != nil {
|
if err = dbclient.Client.Panel.UpdateMessageId(panel.PanelId, msgId); err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, utils.ErrorJson(err))
|
ctx.JSON(500, utils.ErrorJson(err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
|||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc
|
github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc
|
||||||
github.com/TicketsBot/common v0.0.0-20220703211704-f792aa9f0c42
|
github.com/TicketsBot/common v0.0.0-20220703211704-f792aa9f0c42
|
||||||
github.com/TicketsBot/database v0.0.0-20220803192010-3003f6bfcb73
|
github.com/TicketsBot/database v0.0.0-20220804212316-6ff58741a775
|
||||||
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c
|
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c
|
||||||
github.com/TicketsBot/worker v0.0.0-20220802140902-30ca73aea6b8
|
github.com/TicketsBot/worker v0.0.0-20220802140902-30ca73aea6b8
|
||||||
github.com/apex/log v1.1.2
|
github.com/apex/log v1.1.2
|
||||||
|
2
go.sum
2
go.sum
@ -41,6 +41,8 @@ github.com/TicketsBot/common v0.0.0-20220703211704-f792aa9f0c42 h1:3/qnbrEfL8gqS
|
|||||||
github.com/TicketsBot/common v0.0.0-20220703211704-f792aa9f0c42/go.mod h1:WxHh6bY7KhIqdayeOp5f0Zj2NNi/7QqCQfMEqHnpdAM=
|
github.com/TicketsBot/common v0.0.0-20220703211704-f792aa9f0c42/go.mod h1:WxHh6bY7KhIqdayeOp5f0Zj2NNi/7QqCQfMEqHnpdAM=
|
||||||
github.com/TicketsBot/database v0.0.0-20220803192010-3003f6bfcb73 h1:+KDNvovOyjYRIhoZvP2thtGvjQ4EI56Cf7rgXsQDhPE=
|
github.com/TicketsBot/database v0.0.0-20220803192010-3003f6bfcb73 h1:+KDNvovOyjYRIhoZvP2thtGvjQ4EI56Cf7rgXsQDhPE=
|
||||||
github.com/TicketsBot/database v0.0.0-20220803192010-3003f6bfcb73/go.mod h1:gAtOoQKZfCkQ4AoNWQUSl51Fnlqk+odzD/hZ1e1sXyI=
|
github.com/TicketsBot/database v0.0.0-20220803192010-3003f6bfcb73/go.mod h1:gAtOoQKZfCkQ4AoNWQUSl51Fnlqk+odzD/hZ1e1sXyI=
|
||||||
|
github.com/TicketsBot/database v0.0.0-20220804212316-6ff58741a775 h1:QQwI2vEzGJmYESktKxDACA3EdtTBJWwo5elRcDxncbQ=
|
||||||
|
github.com/TicketsBot/database v0.0.0-20220804212316-6ff58741a775/go.mod h1:gAtOoQKZfCkQ4AoNWQUSl51Fnlqk+odzD/hZ1e1sXyI=
|
||||||
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c h1:OqGjFH6mbE6gd+NqI2ARJdtH3UUvhiAkD0r0fhGJK2s=
|
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c h1:OqGjFH6mbE6gd+NqI2ARJdtH3UUvhiAkD0r0fhGJK2s=
|
||||||
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c/go.mod h1:jgi2OXQKsd5nUnTIRkwvPmeuD/i7OhN68LKMssuQY1c=
|
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c/go.mod h1:jgi2OXQKsd5nUnTIRkwvPmeuD/i7OhN68LKMssuQY1c=
|
||||||
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM=
|
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user