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 f3bcee7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
13 changes: 8 additions & 5 deletions internal/nostr/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
)

const (
NIP_47_INFO_EVENT_KIND = 13194
NIP_47_REQUEST_KIND = 23194
NIP_47_RESPONSE_KIND = 23195
NIP_47_NOTIFICATION_KIND = 23196
NIP_47_INFO_EVENT_KIND = 13194
NIP_47_REQUEST_KIND = 23194
NIP_47_RESPONSE_KIND = 23195
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 @@ -168,7 +169,8 @@ type NIP47NotificationRequest struct {
RelayUrl string `json:"relayUrl"`
WebhookUrl string `json:"webhookUrl"`
WalletPubkey string `json:"walletPubkey"`
ConnPubkey string `json:"connectionPubkey"`
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 f3bcee7

Please sign in to comment.