Skip to content

Commit

Permalink
feat: allow version to subscribe to nip-44 encrypted notifs
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Jan 16, 2025
1 parent 7e89304 commit fb4ee0e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion internal/nostr/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const (
NIP_47_INFO_EVENT_KIND = 13194
NIP_47_REQUEST_KIND = 23194
NIP_47_RESPONSE_KIND = 23195
NIP_47_NOTIFICATION_KIND = 23196
LEGACY_NIP_47_NOTIFICATION_KIND = 23196
NIP_47_NOTIFICATION_KIND = 23197

REQUEST_EVENT_PUBLISH_CONFIRMED = "CONFIRMED"
REQUEST_EVENT_PUBLISH_FAILED = "FAILED"
Expand Down Expand Up @@ -169,6 +170,7 @@ type NIP47NotificationRequest struct {
WebhookUrl string `json:"webhookUrl"`
WalletPubkey string `json:"walletPubkey"`
ConnPubkey string `json:"connectionPubkey"`
Version string `json:"version"`
}

type NIP47PushNotificationRequest struct {
Expand All @@ -177,6 +179,7 @@ type NIP47PushNotificationRequest struct {
WalletPubkey string `json:"walletPubkey"`
ConnPubkey string `json:"connectionPubkey"`
IsIOS bool `json:"isIOS"`
Version string `json:"version"`
}

type NIP47Response struct {
Expand Down
6 changes: 5 additions & 1 deletion internal/nostr/nostr.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,11 @@ func (svc *Service) NIP47NotificationHandler(c echo.Context) error {
Open: true,
Since: time.Now(),
Authors: &[]string{requestData.WalletPubkey},
Kinds: &[]int{NIP_47_NOTIFICATION_KIND},
Kinds: &[]int{LEGACY_NIP_47_NOTIFICATION_KIND},
}

if (requestData.Version == "1.0") {
subscription.Kinds = &[]int{NIP_47_NOTIFICATION_KIND}
}

tags := make(nostr.TagMap)
Expand Down
6 changes: 5 additions & 1 deletion internal/nostr/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ func (svc *Service) NIP47PushNotificationHandler(c echo.Context) error {
Open: true,
Since: time.Now(),
Authors: &[]string{requestData.WalletPubkey},
Kinds: &[]int{NIP_47_NOTIFICATION_KIND},
Kinds: &[]int{LEGACY_NIP_47_NOTIFICATION_KIND},
}

if (requestData.Version == "1.0") {
subscription.Kinds = &[]int{NIP_47_NOTIFICATION_KIND}
}

tags := make(nostr.TagMap)
Expand Down

0 comments on commit fb4ee0e

Please sign in to comment.