Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ dist-ssr
*.njsproj
*.sln
*.sw?

go.work
go.work.sum
2 changes: 1 addition & 1 deletion backend/app/http/endpoints/api/analytics/panels.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ GROUP BY p.panel_id, p.default_team;`
group.Go(func() error {
// The primary key is "id". "multi_panel_id" is the FK name on
// multi_panel_targets, not a column here.
query := `SELECT id, embed->>'title' FROM multi_panels WHERE guild_id = $1;`
query := `SELECT id, COALESCE(NULLIF(name, ''), embed->>'title') FROM multi_panels WHERE guild_id = $1;`
rows, err := dbclient.Client.Tickets.Query(groupCtx, query, guildId)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions backend/app/http/endpoints/api/gallery/galleryimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,16 @@ func ImportHandler(ctx *gin.Context) {
buttonStyle = int(*listing.ButtonStyle)
}

// The gallery listing's own Name is the human-facing label the submitter gave the
// whole template (e.g. "Basic Support Panel") - a better default for the dashboard-only
// panel Name than Title, which is the Discord-facing embed heading and often reads more
// like end-user copy (e.g. "Need help?").
panelName := listing.Name

panel := database.Panel{
ChannelId: 0, // Will be set if we send a message
GuildId: guildId,
Name: &panelName,
Title: listing.Title,
Content: listing.Content,
Colour: listing.Colour,
Expand Down
11 changes: 8 additions & 3 deletions backend/app/http/endpoints/api/gallery/resubmit.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ func ResubmitHandler(ctx *gin.Context) {
return
}

if panel.MessageUsesComponentsV2 || panel.WelcomeMessageUsesComponentsV2 {
ctx.JSON(http.StatusBadRequest, utils.ErrorStr("Panels that use component-based messages cannot be submitted to the gallery. Switch the panel to a classic message first."))
return
}

if panel.EmojiId != nil {
ctx.JSON(http.StatusBadRequest, utils.ErrorStr("Panels with custom Discord emojis cannot be submitted to the gallery. Please use a standard Unicode emoji instead."))
return
Expand Down Expand Up @@ -294,9 +299,9 @@ func ResubmitHandler(ctx *gin.Context) {
ResourceType: database.AuditResourceGalleryListing,
ResourceId: audit.StringPtr(strconv.Itoa(listingId)),
NewData: map[string]any{
"name": body.Name,
"category": body.Category,
"resubmit": true,
"name": body.Name,
"category": body.Category,
"resubmit": true,
},
})

Expand Down
35 changes: 20 additions & 15 deletions backend/app/http/endpoints/api/gallery/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func SubmitHandler(ctx *gin.Context) {
return
}

if panel.MessageUsesComponentsV2 || panel.WelcomeMessageUsesComponentsV2 {
ctx.JSON(http.StatusBadRequest, utils.ErrorStr("Panels that use component-based messages cannot be submitted to the gallery. Switch the panel to a classic message first."))
return
}

// Validate emoji is unicode only (no custom emoji IDs)
if panel.EmojiId != nil {
ctx.JSON(http.StatusBadRequest, utils.ErrorStr("Panels with custom Discord emojis cannot be submitted to the gallery. Please use a standard Unicode emoji instead."))
Expand Down Expand Up @@ -136,21 +141,21 @@ func SubmitHandler(ctx *gin.Context) {

// Snapshot the panel design fields into a gallery listing
listing := database.GalleryListing{
SubmitterUserId: userId,
SourceGuildId: guildId,
Name: body.Name,
Description: body.Description,
Category: body.Category,
Status: database.GalleryListingStatusPending,
Title: panel.Title,
Content: panel.Content,
Colour: panel.Colour,
ImageUrl: panel.ImageUrl,
ThumbnailUrl: panel.ThumbnailUrl,
ButtonStyle: intToInt16Ptr(panel.ButtonStyle),
ButtonLabel: panel.ButtonLabel,
EmojiName: panel.EmojiName,
WelcomeMessage: welcomeMessageJSON,
SubmitterUserId: userId,
SourceGuildId: guildId,
Name: body.Name,
Description: body.Description,
Category: body.Category,
Status: database.GalleryListingStatusPending,
Title: panel.Title,
Content: panel.Content,
Colour: panel.Colour,
ImageUrl: panel.ImageUrl,
ThumbnailUrl: panel.ThumbnailUrl,
ButtonStyle: intToInt16Ptr(panel.ButtonStyle),
ButtonLabel: panel.ButtonLabel,
EmojiName: panel.EmojiName,
WelcomeMessage: welcomeMessageJSON,
}

listingId, err := dbclient.Client.GalleryListings.Create(ctx, listing)
Expand Down
Loading
Loading