create table chats
(
id UUID primary key,
name varchar(128) not null unique,
owner UUID not null
)
create table messages
(
id UUID primary key,
chatId UUID not null references chats (id),
author UUID not null,
content text not null,
created_at timestamp default now()
)
create table chats_users
(
chatId UUID references chats (id),
userId UUID,
muted boolean,
primary key (chatId, userId)
)Authorization: Bearer JWT
GET /api/chats
Response:
[
{
"id": "uuid",
"name": "string",
"owner": "uuid"
}
]POST /api/chats
Body:
{
"name": "string",
"users": [
"uuid"
]
}Response:
{
"id": "uuid",
"name": "string",
"owner": "uuid"
}GET /api/chats/{id}
Response:
{
"id": "uuid",
"name": "string",
"owner": "uuid"
}GET /api/chats/{id}/users
Response:
[
"uuid"
]POST /api/chats/{id}/users
Body:
{
"users": [
"uuid"
]
}Response: 204
POST /api/chats/{id}/users/{userId}
Response: 204
DELETE /api/chats/{id}/users/{userId}
Response: 204
PATCH /api/chats/{id}/users/{userId}
Body:
{
"muted": true
}Response: 204
GET /api/chats/{id}/messages?limit=100&after={messageId}
Response:
[
{
"id": "uuid",
"author": "uuid",
"content": "string",
"created_at": "timestamp"
}
]WS /ws/chats/{id}
Headers:
Authorization: Bearer JWT