Improve CORS origin handling; extend invoice repo/service and payments dispatch; rate limit and nginx config updates

Made-with: Love
This commit is contained in:
2026-04-29 05:44:59 +00:00
parent 2cb17df4c5
commit a01797e9b2
12 changed files with 224 additions and 35 deletions

View File

@@ -2,6 +2,7 @@ package payments
import (
"context"
"fmt"
"log/slog"
"strconv"
"time"
@@ -19,14 +20,24 @@ func (w *Worker) dispatchEvents(ctx context.Context, u *user.User, p *invoice.Pe
if err := w.dms.Send(ctx, ev, u.Pubkey, vars); err != nil {
slog.Error("dm enqueue", "err", err)
}
confirmed := time.Now().UTC()
data := map[string]any{
"pubkey": u.Pubkey,
"npub": nostr.HexToNpub(u.Pubkey),
"username": u.Username,
"subscription_type": string(u.SubscriptionType),
"is_lifetime": u.IsLifetime(),
"years": p.Years,
"amount_sats": p.AmountSats,
"payment_hash": p.PaymentHash,
"is_renewal": p.IsRenewal,
"confirmed_at": confirmed.Format(time.RFC3339),
"confirmed_at_unix": confirmed.Unix(),
}
if u.IsLifetime() {
data["duration"] = "lifetime"
} else {
data["duration"] = fmt.Sprintf("%dy", p.Years)
}
if u.ExpiresAt != nil {
data["expires_at"] = u.ExpiresAt.UTC().Format(time.RFC3339)