Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

fix: request event state after publishing response #167

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,14 @@ func (svc *Service) HandleEvent(ctx context.Context, sub *nostr.Subscription, ev
svc.handleUnknownMethod(ctx, nip47Request, publishResponse)
}

requestEvent.State = REQUEST_EVENT_STATE_HANDLER_EXECUTED
err = svc.db.Save(&requestEvent).Error
if err != nil {
svc.Logger.WithFields(logrus.Fields{
"nostrPubkey": event.PubKey,
}).Errorf("Failed to save state to nostr event: %v", err)
if requestEvent.State == REQUEST_EVENT_STATE_HANDLER_EXECUTING {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead we can return if there is an error here: https://github.com/getAlby/nostr-wallet-connect-next/blob/master/service.go#L559

and move this code to under that error check. Then we do not check if the state is executing (does this feel a bit strange?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah that sounds better 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

requestEvent.State = REQUEST_EVENT_STATE_HANDLER_EXECUTED
err = svc.db.Save(&requestEvent).Error
if err != nil {
svc.Logger.WithFields(logrus.Fields{
"nostrPubkey": event.PubKey,
}).Errorf("Failed to save state to nostr event: %v", err)
}
}
}

Expand Down
Loading