Skip to content

Commit

Permalink
feat: read/unread states
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed Jan 10, 2024
1 parent e0c422d commit 780bbad
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
130 changes: 130 additions & 0 deletions docs/specs/clients/notify/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions docs/specs/clients/notify/client-sdk-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/specs/clients/notify/data-structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
```

Expand Down

0 comments on commit 780bbad

Please sign in to comment.