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
2 changes: 1 addition & 1 deletion .github/workflows/deploy-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
cache: npm
cache-dependency-path: frontend/package-lock.json

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '24'
cache: npm
cache-dependency-path: frontend/package-lock.json

Expand Down
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
8 changes: 4 additions & 4 deletions backend/app/http/endpoints/api/admin/affiliate/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ func CreateHandler(ctx *gin.Context) {
ResourceType: database.AuditResourceAffiliate,
ResourceId: audit.StringPtr(affiliateCode.Id.String()),
NewData: map[string]any{
"target_user_id": body.UserId,
"code": body.Code,
"target_user_id": body.UserId,
"code": body.Code,
"discount_basis_points": body.DiscountBasisPoints,
"credit_percentage": body.CreditPercentage,
"polar_discount_id": polarDiscountId,
"credit_percentage": body.CreditPercentage,
"polar_discount_id": polarDiscountId,
},
})

Expand Down
30 changes: 15 additions & 15 deletions backend/app/http/endpoints/api/admin/affiliate/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ const (
)

type affiliateCodeEntry struct {
Id string `json:"id"`
UserId string `json:"user_id"`
Username string `json:"username"`
AvatarUrl string `json:"avatar_url,omitempty"`
Code string `json:"code"`
PolarDiscountId *string `json:"polar_discount_id"`
Status string `json:"status"`
DiscountBasisPoints int `json:"discount_basis_points"`
CreditPercentage *int `json:"credit_percentage"`
CreatedAt string `json:"created_at"`
ApprovedAt *string `json:"approved_at"`
ApprovedBy *string `json:"approved_by"`
RevokedAt *string `json:"revoked_at"`
TotalReferrals int `json:"total_referrals"`
RedeemedCredits int `json:"redeemed_credits"`
Id string `json:"id"`
UserId string `json:"user_id"`
Username string `json:"username"`
AvatarUrl string `json:"avatar_url,omitempty"`
Code string `json:"code"`
PolarDiscountId *string `json:"polar_discount_id"`
Status string `json:"status"`
DiscountBasisPoints int `json:"discount_basis_points"`
CreditPercentage *int `json:"credit_percentage"`
CreatedAt string `json:"created_at"`
ApprovedAt *string `json:"approved_at"`
ApprovedBy *string `json:"approved_by"`
RevokedAt *string `json:"revoked_at"`
TotalReferrals int `json:"total_referrals"`
RedeemedCredits int `json:"redeemed_credits"`
}

type listResponse struct {
Expand Down
4 changes: 2 additions & 2 deletions backend/app/http/endpoints/api/admin/affiliate/rates.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ func UpdateRatesHandler(ctx *gin.Context) {
ResourceId: audit.StringPtr(affiliateId.String()),
OldData: map[string]any{
"discount_basis_points": oldBasisPoints,
"credit_percentage": oldCreditPercentage,
"credit_percentage": oldCreditPercentage,
},
NewData: map[string]any{
"discount_basis_points": body.DiscountBasisPoints,
"credit_percentage": body.CreditPercentage,
"credit_percentage": body.CreditPercentage,
},
})

Expand Down
16 changes: 8 additions & 8 deletions backend/app/http/endpoints/api/admin/affiliate/referrals.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
)

type adminReferralEntry struct {
Id string `json:"id"`
ReferredTier string `json:"referred_tier"`
PurchasedDays int `json:"purchased_days"`
CreditDays int `json:"credit_days"`
Status string `json:"status"`
CreatedAt string `json:"created_at"`
RedeemableAt string `json:"redeemable_at"`
RedeemedAt *string `json:"redeemed_at"`
Id string `json:"id"`
ReferredTier string `json:"referred_tier"`
PurchasedDays int `json:"purchased_days"`
CreditDays int `json:"credit_days"`
Status string `json:"status"`
CreatedAt string `json:"created_at"`
RedeemableAt string `json:"redeemable_at"`
RedeemedAt *string `json:"redeemed_at"`
}

type adminReferralsResponse struct {
Expand Down
4 changes: 2 additions & 2 deletions backend/app/http/endpoints/api/admin/analytics/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
)

type usageResponse struct {
Metrics database.GlobalUsageMetrics `json:"metrics"`
TicketsPerDay []database.GlobalTicketsPerDay `json:"tickets_per_day"`
Metrics database.GlobalUsageMetrics `json:"metrics"`
TicketsPerDay []database.GlobalTicketsPerDay `json:"tickets_per_day"`
}

func GetUsageHandler(ctx *gin.Context) {
Expand Down
6 changes: 3 additions & 3 deletions backend/app/http/endpoints/api/admin/featureflags/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ type listResponse struct {
Flags []flagResponse `json:"flags"`
// Environments is what GrowthBook actually has configured, so the UI offers
// real names instead of assuming production and staging.
Environments []string `json:"environments"`
Configured bool `json:"configured"`
FlagsDefaultOn bool `json:"flags_default_on"`
Environments []string `json:"environments"`
Configured bool `json:"configured"`
FlagsDefaultOn bool `json:"flags_default_on"`
}

type flagResponse struct {
Expand Down
12 changes: 6 additions & 6 deletions backend/app/http/endpoints/api/affiliate/redeem.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ func Redeem(ctx *gin.Context) {
ResourceType: database.AuditResourceAffiliateReferral,
ResourceId: audit.StringPtr(affiliateCode.Id.String()),
NewData: map[string]any{
"redeemed_count": result.redeemedCount,
"total_credits": result.totalCredits,
"total_days": result.totalDays,
"tier": result.tier,
"method": result.method,
"referral_ids": result.referralIds,
"redeemed_count": result.redeemedCount,
"total_credits": result.totalCredits,
"total_days": result.totalDays,
"tier": result.tier,
"method": result.method,
"referral_ids": result.referralIds,
},
})

Expand Down
16 changes: 8 additions & 8 deletions backend/app/http/endpoints/api/affiliate/referrals.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ const (
)

type referralResponse struct {
Id string `json:"id"`
ReferredTier string `json:"referred_tier"`
PurchasedDays int `json:"purchased_days"`
CreditDays int `json:"credit_days"`
Status string `json:"status"`
CreatedAt string `json:"created_at"`
RedeemableAt string `json:"redeemable_at"`
RedeemedAt *string `json:"redeemed_at"`
Id string `json:"id"`
ReferredTier string `json:"referred_tier"`
PurchasedDays int `json:"purchased_days"`
CreditDays int `json:"credit_days"`
Status string `json:"status"`
CreatedAt string `json:"created_at"`
RedeemableAt string `json:"redeemable_at"`
RedeemedAt *string `json:"redeemed_at"`
}

type referralsListResponse struct {
Expand Down
12 changes: 6 additions & 6 deletions backend/app/http/endpoints/api/affiliate/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ type statusResponse struct {
}

type affiliateCodeResponse struct {
Id string `json:"id"`
Code string `json:"code"`
Status string `json:"status"`
DiscountBasisPoints int `json:"discount_basis_points"`
CreditPercentage *int `json:"credit_percentage"`
CreatedAt string `json:"created_at"`
Id string `json:"id"`
Code string `json:"code"`
Status string `json:"status"`
DiscountBasisPoints int `json:"discount_basis_points"`
CreditPercentage *int `json:"credit_percentage"`
CreatedAt string `json:"created_at"`
ApprovedAt *string `json:"approved_at"`
}

Expand Down
4 changes: 2 additions & 2 deletions backend/app/http/endpoints/api/analytics/panels.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ agg AS (
GROUP BY panel_id
)
SELECT
p.panel_id, p.title, p.channel_id, p.disabled, p.force_disabled,
p.panel_id, COALESCE(NULLIF(p.name, ''), p.title), p.channel_id, p.disabled, p.force_disabled,
COALESCE(a.ticket_count, 0), COALESCE(a.closed_count, 0),
a.avg_frt_secs, a.avg_resolution_secs, a.avg_rating, COALESCE(a.rating_count, 0),
COALESCE(a.prev_ticket_count, 0), COALESCE(a.prev_closed_count, 0),
Expand Down 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
9 changes: 6 additions & 3 deletions backend/app/http/endpoints/api/gallery/galleryimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ func ImportHandler(ctx *gin.Context) {
}

if premiumTier == premium.None {
panels, err := dbclient.Client.Panel.GetByGuild(ctx, guildId)
panelCount, err := dbclient.Client.Panel.GetPanelCount(ctx, guildId)
if err != nil {
_ = ctx.AbortWithError(http.StatusInternalServerError, app.NewError(err, "Failed to fetch existing panels"))
return
}

if len(panels) >= freePanelLimit {
ctx.JSON(http.StatusPaymentRequired, utils.ErrorStr("Panel quota exceeded: You have %d/%d panels. Purchase premium to unlock more panels.", len(panels), freePanelLimit))
if panelCount >= freePanelLimit {
ctx.JSON(http.StatusPaymentRequired, utils.ErrorStr("Panel quota exceeded: You have %d/%d panels. Purchase premium to unlock more panels.", panelCount, freePanelLimit))
return
}
}
Expand Down Expand Up @@ -141,9 +141,12 @@ func ImportHandler(ctx *gin.Context) {
buttonStyle = int(*listing.ButtonStyle)
}

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 Components v2 cannot be submitted to the gallery. Switch the panel's messages back to Classic 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 Components v2 cannot be submitted to the gallery. Switch the panel's messages back to Classic 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