-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add check for status and replied at #97
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,16 +72,39 @@ func (svc *Service) StartSubscription(ctx context.Context, sub *nostr.Subscripti | |
svc.Logger.Error(result.Error) | ||
return | ||
} | ||
nostrEvent.State = "replied" // TODO: check if publish was successful | ||
nostrEvent.ReplyId = resp.ID | ||
svc.db.Save(&nostrEvent) | ||
svc.Logger.WithFields(logrus.Fields{ | ||
"nostrEventId": nostrEvent.ID, | ||
"eventId": event.ID, | ||
"status": status, | ||
"replyEventId": resp.ID, | ||
"appId": nostrEvent.AppId, | ||
}).Info("Published reply") | ||
if status == nostr.PublishStatusSucceeded { | ||
nostrEvent.State = "replied" | ||
nostrEvent.RepliedAt = time.Now() | ||
svc.db.Save(&nostrEvent) | ||
svc.Logger.WithFields(logrus.Fields{ | ||
"nostrEventId": nostrEvent.ID, | ||
"eventId": event.ID, | ||
"status": status, | ||
"replyEventId": resp.ID, | ||
"appId": nostrEvent.AppId, | ||
}).Info("Published reply") | ||
} else if status == nostr.PublishStatusFailed { | ||
nostrEvent.State = "failed" | ||
svc.db.Save(&nostrEvent) | ||
svc.Logger.WithFields(logrus.Fields{ | ||
"nostrEventId": nostrEvent.ID, | ||
"eventId": event.ID, | ||
"status": status, | ||
"replyEventId": resp.ID, | ||
"appId": nostrEvent.AppId, | ||
}).Info("Failed to publish reply") | ||
} else { | ||
nostrEvent.State = "sent" | ||
svc.db.Save(&nostrEvent) | ||
svc.Logger.WithFields(logrus.Fields{ | ||
"nostrEventId": nostrEvent.ID, | ||
"eventId": event.ID, | ||
"status": status, | ||
"replyEventId": resp.ID, | ||
"appId": nostrEvent.AppId, | ||
}).Info("Reply sent but no response from relay (timeout)") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what should we do in the else case? what other state can status be? and I think we should log/save that one, too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made changes, please review again |
||
} | ||
}() | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you know what other status it can have? and when this could happen?