Skip to content

Commit 39a2efc

Browse files
authored
Update chats.md
1 parent d2865f7 commit 39a2efc

1 file changed

Lines changed: 72 additions & 1 deletion

File tree

docs/chats.md

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ URL для всего вебсокет-релейтед - `/ws/`
55

66
В данный момент есть только 1 Consumer (т.е. View, но для вебсокетов). Это ChatsConsumer, живет на `/ws/chats/`.
77

8-
# ChatsConsumer
8+
## ChatsConsumer
99
`/ws/chats/`
1010

1111
### Подключение
@@ -36,3 +36,74 @@ class EventType(str, Enum):
3636
SET_OFFLINE = "set_offline"
3737
```
3838

39+
#### General events
40+
41+
- EventType.SET_ONLINE
42+
- EventType.SET_OFFLINE
43+
44+
Структура этих event'ов одинаковая.
45+
46+
```json
47+
{
48+
"type": "set_offline",
49+
"content": {
50+
51+
}
52+
}
53+
```
54+
55+
#### Chat-related events
56+
57+
##### EventType.NEW_MESSAGE
58+
59+
```json
60+
{
61+
"type": "new_message",
62+
"content": {
63+
"chat_type": {{"direct" | "project"}},
64+
"chat_id": {{"id1"_"id2"}}, // например: 1_2
65+
"message": {{string}},
66+
"reply_to": number | null
67+
}
68+
}
69+
```
70+
71+
![[img/event_new_message.png]]
72+
73+
##### EventType.TYPING
74+
75+
```json
76+
{
77+
"type": "typing",
78+
"content": {
79+
"chat_type": {{"direct" | "project"}},
80+
"chat_id": {{"id1"_"id2"}}, // например: 1_2
81+
}
82+
}
83+
```
84+
85+
##### EventType.READ_MESSAGE
86+
87+
```json
88+
{
89+
"type": "typing",
90+
"content": {
91+
"chat_type": {{"direct" | "project"}},
92+
"chat_id": {{"id1"_"id2"}}, // например: 1_2
93+
"message_id": {{number}}
94+
}
95+
}
96+
```
97+
98+
##### EventType.DELETE_MESSAGE
99+
100+
```json
101+
{
102+
"type": "typing",
103+
"content": {
104+
"chat_type": {{"direct" | "project"}},
105+
"chat_id": {{"id1"_"id2"}}, // например: 1_2
106+
"message_id": {{number}}
107+
}
108+
}
109+
```

0 commit comments

Comments
 (0)