migrations
This commit is contained in:
parent
7336d50d62
commit
90d6b5f72a
@ -137,7 +137,7 @@ func CreatePanel(ctx *gin.Context) {
|
||||
// string is role ID or "user" to mention the ticket opener
|
||||
for _, mention := range data.Mentions {
|
||||
if mention == "user" {
|
||||
if err = dbclient.Client.PanelUserMention.Set(msgId, true); err != nil {
|
||||
if err = dbclient.Client.PanelUserMention.Set(panelId, true); err != nil {
|
||||
ctx.AbortWithStatusJSON(500, gin.H{
|
||||
"success": false,
|
||||
"error": err.Error(),
|
||||
@ -157,7 +157,7 @@ func CreatePanel(ctx *gin.Context) {
|
||||
// should we check the role is a valid role in the guild?
|
||||
// not too much of an issue if it isnt
|
||||
|
||||
if err = dbclient.Client.PanelRoleMentions.Add(msgId, roleId); err != nil {
|
||||
if err = dbclient.Client.PanelRoleMentions.Add(panelId, roleId); err != nil {
|
||||
ctx.AbortWithStatusJSON(500, gin.H{
|
||||
"success": false,
|
||||
"error": err.Error(),
|
||||
@ -214,7 +214,7 @@ func (p *panelBody) doValidations(ctx *gin.Context, guildId uint64) bool {
|
||||
if !p.verifyTitle() {
|
||||
ctx.AbortWithStatusJSON(400, gin.H{
|
||||
"success": false,
|
||||
"error": "Panel titles must be between 1 - 255 characters in length",
|
||||
"error": "Panel titles must be between 1 - 80 characters in length",
|
||||
})
|
||||
return false
|
||||
}
|
||||
@ -266,7 +266,7 @@ func (p *panelBody) doValidations(ctx *gin.Context, guildId uint64) bool {
|
||||
}
|
||||
|
||||
func (p *panelBody) verifyTitle() bool {
|
||||
return len(p.Title) > 0 && len(p.Title) < 256
|
||||
return len(p.Title) > 0 && len(p.Title) <= 80
|
||||
}
|
||||
|
||||
func (p *panelBody) verifyContent() bool {
|
||||
|
@ -48,7 +48,7 @@ func ListPanels(ctx *gin.Context) {
|
||||
var mentions []string
|
||||
|
||||
// get role mentions
|
||||
roles, err := dbclient.Client.PanelRoleMentions.GetRoles(p.MessageId)
|
||||
roles, err := dbclient.Client.PanelRoleMentions.GetRoles(p.PanelId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -59,7 +59,7 @@ func ListPanels(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
// get if we should mention the ticket opener
|
||||
shouldMention, err := dbclient.Client.PanelUserMention.ShouldMentionUser(p.MessageId)
|
||||
shouldMention, err := dbclient.Client.PanelUserMention.ShouldMentionUser(p.PanelId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -166,24 +166,16 @@ func UpdatePanel(ctx *gin.Context) {
|
||||
|
||||
// insert role mention data
|
||||
// delete old data
|
||||
if err = dbclient.Client.PanelRoleMentions.DeleteAll(newMessageId); err != nil {
|
||||
ctx.AbortWithStatusJSON(500, utils.ErrorJson(err))
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Reduce to 1 query
|
||||
if err = dbclient.Client.PanelUserMention.Set(newMessageId, false); err != nil {
|
||||
if err = dbclient.Client.PanelRoleMentions.DeleteAll(panel.PanelId); err != nil {
|
||||
ctx.AbortWithStatusJSON(500, utils.ErrorJson(err))
|
||||
return
|
||||
}
|
||||
|
||||
// string is role ID or "user" to mention the ticket opener
|
||||
var shouldMentionUser bool
|
||||
for _, mention := range data.Mentions {
|
||||
if mention == "user" {
|
||||
if err = dbclient.Client.PanelUserMention.Set(newMessageId, true); err != nil {
|
||||
ctx.AbortWithStatusJSON(500, utils.ErrorJson(err))
|
||||
return
|
||||
}
|
||||
shouldMentionUser = true
|
||||
} else {
|
||||
roleId, err := strconv.ParseUint(mention, 10, 64)
|
||||
if err != nil {
|
||||
@ -193,14 +185,18 @@ func UpdatePanel(ctx *gin.Context) {
|
||||
|
||||
// should we check the role is a valid role in the guild?
|
||||
// not too much of an issue if it isnt
|
||||
|
||||
if err = dbclient.Client.PanelRoleMentions.Add(newMessageId, roleId); err != nil {
|
||||
if err = dbclient.Client.PanelRoleMentions.Add(panel.PanelId, roleId); err != nil {
|
||||
ctx.AbortWithStatusJSON(500, utils.ErrorJson(err))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err = dbclient.Client.PanelUserMention.Set(panel.PanelId, shouldMentionUser); err != nil {
|
||||
ctx.AbortWithStatusJSON(500, utils.ErrorJson(err))
|
||||
return
|
||||
}
|
||||
|
||||
// insert support teams
|
||||
// TODO: Stop race conditions - 1 transaction
|
||||
// delete teams
|
||||
|
8
go.mod
8
go.mod
@ -5,9 +5,9 @@ go 1.14
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb
|
||||
github.com/TicketsBot/common v0.0.0-20210508230445-142f7765b87f
|
||||
github.com/TicketsBot/database v0.0.0-20210526225555-040a69389e53
|
||||
github.com/TicketsBot/worker v0.0.0-20210526230503-cf3fa42fed99
|
||||
github.com/TicketsBot/common v0.0.0-20210527174309-f7344004ae32
|
||||
github.com/TicketsBot/database v0.0.0-20210528120222-49534148fc63
|
||||
github.com/TicketsBot/worker v0.0.0-20210528120548-e0e37646be05
|
||||
github.com/apex/log v1.1.2
|
||||
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
@ -21,7 +21,7 @@ require (
|
||||
github.com/jackc/pgx/v4 v4.7.1
|
||||
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rxdn/gdl v0.0.0-20210527124215-63f4791eb845
|
||||
github.com/rxdn/gdl v0.0.0-20210527190730-a6b87abf7fc8
|
||||
github.com/sirupsen/logrus v1.5.0
|
||||
github.com/ulule/limiter/v3 v3.5.0
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
|
||||
|
Loading…
x
Reference in New Issue
Block a user