Skip to content

Commit

Permalink
fix: expiresAt and maxAmount handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Nov 3, 2023
1 parent e75ad07 commit 69f2a19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions echo_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,13 @@ 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, err := time.Parse(time.RFC3339, c.FormValue("ExpiresAt"))
if (err != nil) {
return fmt.Errorf("Invalid ExpiresAt: %v", err)

expiresAt := time.Time{}
if c.FormValue("ExpiresAt") != "" {
expiresAt, err = time.Parse(time.RFC3339, c.FormValue("ExpiresAt"))
if (err != nil) {
return fmt.Errorf("Invalid ExpiresAt: %v", err)
}
}

if !expiresAt.IsZero() {
Expand Down
4 changes: 2 additions & 2 deletions views/apps/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ <h2 class="font-bold text-2xl font-headline mb-4 dark:text-white">
<input type="hidden" name="name" id="" value="{{.Name}}">
{{end}}
<input type="hidden" name="RequestMethods" id="request-methods" value={{.RequestMethods}}>
<input type="hidden" name="ExpiresAt" id="expires-at" value={{.ExpiresAt}}>
<input type="hidden" name="MaxAmount" id="max-amount" value={{.MaxAmount}}>
<input type="hidden" name="ExpiresAt" id="expires-at" value="{{.ExpiresAt}}">
<input type="hidden" name="MaxAmount" id="max-amount" value="{{.MaxAmount}}">
<input type="hidden" name="BudgetRenewal" id="budget-renewal" value={{if .BudgetRenewal}}{{.BudgetRenewal}}{{else}}{{"monthly"}}{{end}}>
</div>

Expand Down

0 comments on commit 69f2a19

Please sign in to comment.