Skip to content

Commit 0c46667

Browse files
AchoArnoldCopilot
andcommitted
fix: address usage email review feedback
Format billing period dates in UTC to match how billing cycle boundaries are computed, and change IsEntitled to <= limit so users get the full message allowance and the exceeded email total matches the stated limit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b660f09 commit 0c46667

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

api/pkg/emails/hermes_user_email_factory.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ type hermesUserEmailFactory struct {
1515
generator hermes.Hermes
1616
}
1717

18-
// formatBillingDate renders a date like "19 June 2026"
18+
// formatBillingDate renders a date like "19 June 2026" in UTC, matching how
19+
// the billing cycle boundaries are computed in the billing usage repository.
1920
func formatBillingDate(t time.Time) string {
20-
return t.Format("2 January 2006")
21+
return t.UTC().Format("2 January 2006")
2122
}
2223

2324
func (factory *hermesUserEmailFactory) APIKeyRotated(emailAddress string, timestamp time.Time, timezone string) (*Email, error) {

api/pkg/entities/billing_usage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (usage *BillingUsage) TotalMessages() uint {
2424
return usage.SentMessages + usage.ReceivedMessages
2525
}
2626

27-
// IsEntitled checks if a user can send `count` messages
27+
// IsEntitled checks if a user can send `count` messages without exceeding `limit`
2828
func (usage *BillingUsage) IsEntitled(count, limit uint) bool {
29-
return (usage.TotalMessages() + count) < limit
29+
return (usage.TotalMessages() + count) <= limit
3030
}

0 commit comments

Comments
 (0)