From c64f52766a96a6a6415b0c9c547d76c8bc98b966 Mon Sep 17 00:00:00 2001 From: im-adithya Date: Wed, 13 Dec 2023 21:17:53 +0530 Subject: [PATCH 1/2] chore: use pay_invoice permissions --- handle_pay_keysend_request.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/handle_pay_keysend_request.go b/handle_pay_keysend_request.go index 35815749..a5b8ae30 100644 --- a/handle_pay_keysend_request.go +++ b/handle_pay_keysend_request.go @@ -33,11 +33,8 @@ func (svc *Service) HandlePayKeysendEvent(ctx context.Context, request *Nip47Req return nil, err } - hasPermission, code, message := svc.hasPermission(&app, event, request.Method, 0) - if hasPermission { - // We use pay_invoice permissions for budget and max amount - hasPermission, code, message = svc.hasPermission(&app, event, NIP_47_PAY_INVOICE_METHOD, payParams.Amount) - } + // We use pay_invoice permissions for budget and max amount + hasPermission, code, message := svc.hasPermission(&app, event, NIP_47_PAY_INVOICE_METHOD, payParams.Amount) if !hasPermission { svc.Logger.WithFields(logrus.Fields{ From 27c458912930adeaac292d6a4e13cbbc917d4e28 Mon Sep 17 00:00:00 2001 From: im-adithya Date: Wed, 13 Dec 2023 21:19:57 +0530 Subject: [PATCH 2/2] fix: remove unnecessary permission creation in test --- service_test.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/service_test.go b/service_test.go index f8104482..fd4496ee 100644 --- a/service_test.go +++ b/service_test.go @@ -314,13 +314,6 @@ func TestHandleEvent(t *testing.T) { newMaxAmount = 1000 err = svc.db.Model(&AppPermission{}).Where("app_id = ?", app.ID).Update("request_method", NIP_47_PAY_INVOICE_METHOD).Update("max_amount", newMaxAmount).Error assert.NoError(t, err) - // create a second permission for getting the budget - appPermission = &AppPermission{ - AppId: app.ID, - App: app, - RequestMethod: NIP_47_PAY_KEYSEND_METHOD, - ExpiresAt: expiresAt, - } err = svc.db.Create(appPermission).Error res, err = svc.HandleEvent(ctx, &nostr.Event{ ID: "test_pay_keysend_event_2",