From 780bbad1bad046a2bae37e3768d8dd00d61a9510 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 10 Jan 2024 17:38:17 -0500 Subject: [PATCH 1/3] feat: read/unread states --- docs/specs/clients/notify/authentication.md | 130 +++++++++++++++++++ docs/specs/clients/notify/client-sdk-api.md | 3 + docs/specs/clients/notify/data-structures.md | 2 + 3 files changed, 135 insertions(+) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index d931f882..5673b72c 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -177,6 +177,136 @@ Paginated list of notifications with the most recently sent first. Unread notifi | Tag | 4015 | | Topic | notify topic | +## `wc_notifyNotificationChanged` + +Emitted by the Notify Server when a notification changed state. For example if its read status changed. + +### Request + +- act - `notify_notification_changed` +- iss - did:key of dapp authentication key +- aud - did:key of client identity key +- nfn - array of [Notify Notification](./data-structures.md#notify-notification) + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4018 | +| Topic | notify topic | + +### Response + +- act - `notify_notification_changed_response` +- iss - did:key of client identity key +- ksu - key server for identity key verification +- aud - did:key of dapp authentication key + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4019 | +| Topic | notify topic | + +## `wc_notifyReadNotification` + +Marks a notification as read. + +### Request + +- act - `notify_read_notification` +- iss - did:key of client identity key +- ksu - key server for identity key verification +- aud - did:key of dapp authentication key +- app - did:web of app domain that this request is associated with + - Example: `did:web:app.example.com` +- ids - array of notification IDs to mark as read, max 1000 items + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4020 | +| Topic | notify topic | + +### Response + +- act - `notify_read_notification_response` +- iss - did:key of dapp authentication key +- aud - did:key of client identity key + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4021 | +| Topic | notify topic | + +## `wc_notifyGetUnreadNotificationsCount` + +Returns a count of how many notifications are unread. Useful to implement unread notification counters, without needing to go through `O(n)` round trips of pages to count the total client-side. + +### Request + +- act - `notify_get_unread_notifications_count` +- iss - did:key of client identity key +- ksu - key server for identity key verification +- aud - did:key of dapp authentication key +- app - did:web of app domain that this request is associated with + - Example: `did:web:app.example.com` + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4022 | +| Topic | notify topic | + +### Response + +- act - `notify_get_unread_notifications_count_response` +- iss - did:key of dapp authentication key +- aud - did:key of client identity key +- cnt - number of unread notifications + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4023 | +| Topic | notify topic | + ## Noop Noop message sent by the Notify Server after subscription creation to mark a topic as long-lived so the relay does not destroy it. Clients should ignore this message. diff --git a/docs/specs/clients/notify/client-sdk-api.md b/docs/specs/clients/notify/client-sdk-api.md index 3ec0d020..e17e41b2 100644 --- a/docs/specs/clients/notify/client-sdk-api.md +++ b/docs/specs/clients/notify/client-sdk-api.md @@ -43,9 +43,12 @@ abstract class Client { // Default 10, max 50 limit?: number, startingAfter?: string, + // Default false + unreadFirst?: string, }): Promise<{ notifications: NotifyNotificationRecord[], hasMore: boolean, + hasMoreUnread: boolean, }> // get notification by ID diff --git a/docs/specs/clients/notify/data-structures.md b/docs/specs/clients/notify/data-structures.md index afccf24f..177c7534 100644 --- a/docs/specs/clients/notify/data-structures.md +++ b/docs/specs/clients/notify/data-structures.md @@ -34,6 +34,8 @@ icon: string, // Redirect URL for call-to-action related to notification. If empty, do not redirect url: string, + // If the notification was read or not + read: boolean, } ``` From 28e13243a9a89da081afef4d6380ba233912180b Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 10 Jan 2024 17:38:46 -0500 Subject: [PATCH 2/3] feat: get single notification --- docs/specs/clients/notify/authentication.md | 45 +++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index 5673b72c..b0efa071 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -177,6 +177,51 @@ Paginated list of notifications with the most recently sent first. Unread notifi | Tag | 4015 | | Topic | notify topic | +## `wc_notifyGetNotification` + +Get one notification by ID. Useful for URL links where you need to retrieve a specific notification and display it without needing to go through `O(n)` round trips of pages to find the notification client-side. + +### Request + +- act - `notify_get_notification` +- iss - did:key of client identity key +- ksu - key server for identity key verification +- aud - did:key of dapp authentication key +- app - did:web of app domain that this request is associated with + - Example: `did:web:app.example.com` +- id - the notification ID to retrieve + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4016 | +| Topic | notify topic | + +### Response + +- act - `notify_get_notification_response` +- iss - did:key of client identity key +- aud - did:key of dapp authentication key +- nfn - [Notify Notification](./data-structures.md#notify-notification) + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4017 | +| Topic | notify topic | + ## `wc_notifyNotificationChanged` Emitted by the Notify Server when a notification changed state. For example if its read status changed. From 4a423abd330d146f51ed896a6946d1ae7f5cae7b Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 5 Feb 2024 14:50:00 -0500 Subject: [PATCH 3/3] chore: add back getNotification --- docs/specs/clients/notify/client-sdk-api.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/specs/clients/notify/client-sdk-api.md b/docs/specs/clients/notify/client-sdk-api.md index d142bb89..0a237575 100644 --- a/docs/specs/clients/notify/client-sdk-api.md +++ b/docs/specs/clients/notify/client-sdk-api.md @@ -51,6 +51,12 @@ abstract class Client { hasMoreUnread: boolean, }> + // get notification by ID + public abstract getNotification(params: { + topic: string, + id: string, + }): Promise + // delete active subscription public abstract deleteSubscription(params: { topic: string,