diff --git a/app/http/endpoints/api/panelcreate.go b/app/http/endpoints/api/panelcreate.go index bfc3820..a8072c3 100644 --- a/app/http/endpoints/api/panelcreate.go +++ b/app/http/endpoints/api/panelcreate.go @@ -25,7 +25,7 @@ func CreatePanel(ctx *gin.Context) { if err != nil { ctx.AbortWithStatusJSON(500, gin.H{ "success": false, - "error": err.Error(), + "error": err.Error(), }) return } @@ -114,6 +114,7 @@ func CreatePanel(ctx *gin.Context) { Colour: int32(data.Colour), TargetCategory: data.CategoryId, ReactionEmote: emoji, + WelcomeMessage: data.WelcomeMessage, } if err = dbclient.Client.Panel.Create(panel); err != nil { @@ -125,7 +126,7 @@ func CreatePanel(ctx *gin.Context) { } ctx.JSON(200, gin.H{ - "success": true, + "success": true, "message_id": strconv.FormatUint(msgId, 10), }) } @@ -174,6 +175,14 @@ func (p *panel) doValidations(ctx *gin.Context, guildId uint64) bool { return false } + if !p.verifyWelcomeMessage() { + ctx.AbortWithStatusJSON(400, gin.H{ + "success": false, + "error": "Welcome message must be null or between 1 - 1024 characters", + }) + return false + } + return true } @@ -216,6 +225,10 @@ func (p *panel) verifyCategory(channels []channel.Channel) bool { return valid } +func (p *panel) verifyWelcomeMessage() bool { + return p.WelcomeMessage == nil || (len(*p.WelcomeMessage) > 0 && len(*p.WelcomeMessage) < 1025) +} + func (p *panel) sendEmbed(ctx *botcontext.BotContext, isPremium bool) (messageId uint64, err error) { e := embed.NewEmbed(). SetTitle(p.Title). diff --git a/app/http/endpoints/api/panellist.go b/app/http/endpoints/api/panellist.go index e3cd50f..337838e 100644 --- a/app/http/endpoints/api/panellist.go +++ b/app/http/endpoints/api/panellist.go @@ -6,13 +6,14 @@ import ( ) type panel struct { - ChannelId uint64 `json:"channel_id,string"` - MessageId uint64 `json:"message_id,string"` - Title string `json:"title"` - Content string `json:"content"` - Colour uint32 `json:"colour"` - CategoryId uint64 `json:"category_id,string"` - Emote string `json:"emote"` + ChannelId uint64 `json:"channel_id,string"` + MessageId uint64 `json:"message_id,string"` + Title string `json:"title"` + Content string `json:"content"` + Colour uint32 `json:"colour"` + CategoryId uint64 `json:"category_id,string"` + Emote string `json:"emote"` + WelcomeMessage *string `json:"welcome_message"` } func ListPanels(ctx *gin.Context) { @@ -22,7 +23,7 @@ func ListPanels(ctx *gin.Context) { if err != nil { ctx.AbortWithStatusJSON(500, gin.H{ "success": false, - "error": err.Error(), + "error": err.Error(), }) return } @@ -31,13 +32,14 @@ func ListPanels(ctx *gin.Context) { for i, p := range panels { wrapped[i] = panel{ - ChannelId: p.ChannelId, - MessageId: p.MessageId, - Title: p.Title, - Content: p.Content, - Colour: uint32(p.Colour), - CategoryId: p.TargetCategory, - Emote: p.ReactionEmote, + ChannelId: p.ChannelId, + MessageId: p.MessageId, + Title: p.Title, + Content: p.Content, + Colour: uint32(p.Colour), + CategoryId: p.TargetCategory, + Emote: p.ReactionEmote, + WelcomeMessage: p.WelcomeMessage, } } diff --git a/go.mod b/go.mod index d3051d5..6a38887 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/BurntSushi/toml v0.3.1 github.com/TicketsBot/archiverclient v0.0.0-20200425115930-0ca198cc8306 github.com/TicketsBot/common v0.0.0-20200529141045-7426ad13f1a4 - github.com/TicketsBot/database v0.0.0-20200613162408-5b3847cebd07 + github.com/TicketsBot/database v0.0.0-20200614182426-d117a0e3f769 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 diff --git a/public/templates/views/panels.tmpl b/public/templates/views/panels.tmpl index 60e9400..f6d7066 100644 --- a/public/templates/views/panels.tmpl +++ b/public/templates/views/panels.tmpl @@ -85,9 +85,30 @@ +
Error | +Error | +Date |
---|