(API) push subscription (#615)
* (API) push subscription * (API) push subscription * (API) push subscription * (API) push subscription * (API) push subscription * (API) push subscription * (API) push subscription
This commit is contained in:
parent
519f6c49ec
commit
57db71f7f2
|
@ -34,6 +34,7 @@ API overview
|
|||
- [List](#list)
|
||||
- [Mention](#mention)
|
||||
- [Notification](#notification)
|
||||
- [Push Subscription](#push-subscription)
|
||||
- [Relationship](#relationship)
|
||||
- [Results](#results)
|
||||
- [Status](#status)
|
||||
|
@ -533,6 +534,56 @@ Form data:
|
|||
Deletes a single notification from the Mastodon server for the authenticated user.
|
||||
Returns an empty object.
|
||||
|
||||
#### Adding push subscription
|
||||
|
||||
POST /api/v1/push/subscription
|
||||
|
||||
Form data:
|
||||
|
||||
| Field | Description | Optional |
|
||||
| ---------------------------- | ---------------------------------------------------------------------------------------------------- | -------- |
|
||||
| `subscription[endpoint]` | Endpoint URL that called when notification is happen. | no |
|
||||
| `subscription[keys][p256dh]` | User agent public key. Base64 encoded string of public key of ECDH key that using 'prime256v1' curve. | no |
|
||||
| `subscription[keys][auth]` | Auth secret. Base64 encoded string of 16 bytes random data. | no |
|
||||
| `data[alerts][follow]` | Boolean of whether you want to receive follow notification event. | ? |
|
||||
| `data[alerts][favourite]` | Boolean of whether you want to receive favourite notification event. | ? |
|
||||
| `data[alerts][reblog]` | Boolean of whether you want to receive reblog notification event. | ? |
|
||||
| `data[alerts][mention]` | Boolean of whether you want to receive mention notification event. | ? |
|
||||
|
||||
Returns the [Push Subscription](#push-subscription).
|
||||
|
||||
Each access token can have one push subscription.
|
||||
If you post new subscription. the old subscription is deleted.
|
||||
|
||||
The endpoint URL is called when notification event is happen,
|
||||
and its payload is encrypted according to The Web Push Protocol.
|
||||
see also:
|
||||
- https://developers.google.com/web/updates/2016/03/web-push-encryption
|
||||
- https://developers.google.com/web/fundamentals/push-notifications/web-push-protocol
|
||||
|
||||
#### Get current push subscription status
|
||||
|
||||
GET /api/v1/push/subscription
|
||||
|
||||
Returns the [Push Subscription](#push-subscription).
|
||||
|
||||
#### Updating push subscription
|
||||
|
||||
PUT /api/v1/push/subscription
|
||||
|
||||
Returns the [Push Subscription](#push-subscription).
|
||||
|
||||
This API updates 'data' part of push subscription.
|
||||
If you want to change 'subscription', you have to use 'POST /api/v1/push/subscription'.
|
||||
|
||||
#### Removing push subscription
|
||||
|
||||
DELETE /api/v1/push/subscription
|
||||
|
||||
This API removes push subscription that bind to access token.
|
||||
|
||||
|
||||
|
||||
### Reports
|
||||
|
||||
#### Fetching a user's reports:
|
||||
|
@ -834,6 +885,14 @@ The most important part of an error response is the HTTP status code. Standard s
|
|||
| `account` | The [Account](#account) sending the notification to the user | no |
|
||||
| `status` | The [Status](#status) associated with the notification, if applicable | yes |
|
||||
|
||||
### Push Subscription
|
||||
| Attribute | Description | Nullable |
|
||||
| ------------------------ | --------------------------------------------------------------- | -------- |
|
||||
| `id` | The push subscription ID | no |
|
||||
| `endpoint` | The endpoint URL | no |
|
||||
| `server_key` | The server public key for signature verification. (not for decoding) | no |
|
||||
| `alerts` | Map of 'notification event type' and 'push is requested or not' | ? |
|
||||
|
||||
### Relationship
|
||||
|
||||
| Attribute | Description | Nullable |
|
||||
|
|
Loading…
Reference in New Issue