Skip to content

cu-drip/team_2_ChatService

Repository files navigation

База Данных

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)
)

REST API

User Scope

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"
}

Получить чат по id

GET /api/chats/{id}
Response:

{
    "id": "uuid",
    "name": "string",
    "owner": "uuid"
}

Получить список участников чата

GET /api/chats/{id}/users
Response:

[
    "uuid"
]

Добавить участников чата (owner only)

POST /api/chats/{id}/users
Body:

{
    "users": [
        "uuid"
    ]
}

Response: 204

Добавить участников чата (owner only)

POST /api/chats/{id}/users/{userId}
Response: 204

Удалить участников чата (owner only)

DELETE /api/chats/{id}/users/{userId}
Response: 204

Замутить/Размутить участника чата (owner and admin only)

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"
    }
]

Websocket API

Подключится к чату

WS /ws/chats/{id}
Headers:

Authorization: Bearer JWT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors