Docs: Align chat api changes with docs.

This commit is contained in:
lain 2020-04-27 17:52:16 +02:00
parent ad82a216ff
commit b550ef5611
1 changed files with 11 additions and 25 deletions

View File

@ -32,33 +32,21 @@ For this reasons, Chats are a new and different entity, both in the API as well
## API ## API
In general, the way to send a `ChatMessage` is to first create a `Chat`, then post a message to that `Chat`. The actors in the API are generally given by their ActivityPub id to make it easier to support later `Group` scenarios. In general, the way to send a `ChatMessage` is to first create a `Chat`, then post a message to that `Chat`. `Group`s will later be supported by making them a sub-type of `Account`.
This is the overview of using the API. The API is also documented via OpenAPI, so you can view it and play with it by pointing SwaggerUI or a similar OpenAPI tool to `https://yourinstance.tld/api/openapi`. This is the overview of using the API. The API is also documented via OpenAPI, so you can view it and play with it by pointing SwaggerUI or a similar OpenAPI tool to `https://yourinstance.tld/api/openapi`.
### Creating or getting a chat. ### Creating or getting a chat.
To create or get an existing Chat for a certain recipient (identified by AP ID) To create or get an existing Chat for a certain recipient (identified by Account ID)
you can call: you can call:
`POST /api/v1/pleroma/chats/by-ap-id/{ap_id}` `POST /api/v1/pleroma/chats/by-account-id/{account_id}`
The ap_id of the recipients needs to be www-form encoded, so The account id is the normal FlakeId of the usre
``` ```
https://originalpatchou.li/user/lambda POST /api/v1/pleroma/chats/by-account-id/someflakeid
```
would become
```
https%3A%2F%2Foriginalpatchou.li%2Fuser%2Flambda
```
The full call would then be
```
POST /api/v1/pleroma/chats/by-ap-id/https%3A%2F%2Foriginalpatchou.li%2Fuser%2Flambda
``` ```
There will only ever be ONE Chat for you and a given recipient, so this call There will only ever be ONE Chat for you and a given recipient, so this call
@ -68,8 +56,7 @@ Returned data:
```json ```json
{ {
"recipient" : "https://dontbulling.me/users/lain", "account": {
"recipient_account": {
"id": "someflakeid", "id": "someflakeid",
"username": "somenick", "username": "somenick",
... ...
@ -91,8 +78,7 @@ Returned data:
```json ```json
[ [
{ {
"recipient" : "https://dontbulling.me/users/lain", "account": {
"recipient_account": {
"id": "someflakeid", "id": "someflakeid",
"username": "somenick", "username": "somenick",
... ...
@ -120,7 +106,7 @@ Returned data:
```json ```json
[ [
{ {
"actor": "https://dontbulling.me/users/lain", "account_id": "someflakeid",
"chat_id": "1", "chat_id": "1",
"content": "Check this out :firefox:", "content": "Check this out :firefox:",
"created_at": "2020-04-21T15:11:46.000Z", "created_at": "2020-04-21T15:11:46.000Z",
@ -135,7 +121,7 @@ Returned data:
"id": "13" "id": "13"
}, },
{ {
"actor": "https://dontbulling.me/users/lain", "account_id": "someflakeid",
"chat_id": "1", "chat_id": "1",
"content": "Whats' up?", "content": "Whats' up?",
"created_at": "2020-04-21T15:06:45.000Z", "created_at": "2020-04-21T15:06:45.000Z",
@ -161,7 +147,7 @@ Returned data:
```json ```json
{ {
"actor": "https://dontbulling.me/users/lain", "account_id": "someflakeid",
"chat_id": "1", "chat_id": "1",
"content": "Check this out :firefox:", "content": "Check this out :firefox:",
"created_at": "2020-04-21T15:11:46.000Z", "created_at": "2020-04-21T15:11:46.000Z",
@ -190,7 +176,7 @@ There's a new `pleroma:chat_mention` notification, which has this form:
"chat_id": "1", "chat_id": "1",
"id": "10", "id": "10",
"content": "Hello", "content": "Hello",
"actor": "https://dontbulling.me/users/lain" "account_id": "someflakeid"
}, },
"created_at": "somedate" "created_at": "somedate"
} }