From f3bcee78322cbc72431cc8be407758e57c1b8e39 Mon Sep 17 00:00:00 2001 From: im-adithya Date: Thu, 16 Jan 2025 16:50:29 +0530 Subject: [PATCH] feat: allow version to subscribe to nip-44 encrypted notifs --- internal/nostr/models.go | 13 ++++++++----- internal/nostr/nostr.go | 6 +++++- internal/nostr/push.go | 6 +++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/internal/nostr/models.go b/internal/nostr/models.go index 7ca9f02..992b78b 100644 --- a/internal/nostr/models.go +++ b/internal/nostr/models.go @@ -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" @@ -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 { @@ -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 { diff --git a/internal/nostr/nostr.go b/internal/nostr/nostr.go index 2690910..3fac226 100644 --- a/internal/nostr/nostr.go +++ b/internal/nostr/nostr.go @@ -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) diff --git a/internal/nostr/push.go b/internal/nostr/push.go index d473528..bab2df9 100644 --- a/internal/nostr/push.go +++ b/internal/nostr/push.go @@ -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)