From 926b8fff7b5af6dcd7f501bcd32f55d6d40d7020 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 | 5 ++++- internal/nostr/nostr.go | 6 +++++- internal/nostr/push.go | 6 +++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/nostr/models.go b/internal/nostr/models.go index 7ca9f02..cff47b2 100644 --- a/internal/nostr/models.go +++ b/internal/nostr/models.go @@ -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" @@ -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 { @@ -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)