diff --git a/README.md b/README.md index 3dd707f2..8a51e261 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ If the client creates the secret the client only needs to share the public key o - `c`: the name of the client app - `pubkey`: the public key of the client's secret for the user to authorize - `return_to`: (optional) if a `return_to` URL is provided the user will be redirected to that URL after authorization. The `lud16`, `relay` and `pubkey` query parameters will be added to the URL. -- `expires_at` (optional) connection cannot be used after this date. Format: 2024-05-23 +- `expires_at` (optional) connection cannot be used after this date. Unix timestamp in seconds. - `max_amount` (optional) maximum amount in sats that can be sent per renewal period - `budget_renewal` (optional) reset the budget at the end of the given budget renewal. Can be `never` (default), `daily`, `weekly`, `monthly`, `yearly` - `editable` (optional) set to `false` to disable form editing by the user diff --git a/echo_handlers.go b/echo_handlers.go index eab35c1c..66f3c928 100644 --- a/echo_handlers.go +++ b/echo_handlers.go @@ -220,7 +220,10 @@ func (svc *Service) AppsNewHandler(c echo.Context) error { returnTo := c.QueryParam("return_to") maxAmount := c.QueryParam("max_amount") budgetRenewal := strings.ToLower(c.QueryParam("budget_renewal")) - expiresAt := c.QueryParam("expires_at") // YYYY-MM-DD or MM/DD/YYYY + expiresAt := c.QueryParam("expires_at") // YYYY-MM-DD or MM/DD/YYYY or timestamp in seconds + if expiresAtTimestamp, err := strconv.Atoi(expiresAt); err == nil { + expiresAt = time.Unix(int64(expiresAtTimestamp), 0).Format(time.RFC3339) + } disabled := c.QueryParam("editable") == "false" budgetEnabled := maxAmount != "" || budgetRenewal != "" csrf, _ := c.Get(middleware.DefaultCSRFConfig.ContextKey).(string) @@ -282,7 +285,7 @@ func (svc *Service) AppsCreateHandler(c echo.Context) error { app := App{Name: name, NostrPubkey: pairingPublicKey} maxAmount, _ := strconv.Atoi(c.FormValue("MaxAmount")) budgetRenewal := c.FormValue("BudgetRenewal") - expiresAt, _ := time.Parse("2006-01-02", c.FormValue("ExpiresAt")) + expiresAt, _ := time.Parse(time.RFC3339, c.FormValue("ExpiresAt")) if !expiresAt.IsZero() { expiresAt = time.Date(expiresAt.Year(), expiresAt.Month(), expiresAt.Day(), 23, 59, 59, 0, expiresAt.Location()) }