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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user