mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 22:18:29 +00:00
support bot, bots: paginate chat scan (#6935)
* bots: document APIGetChats command and CRApiChats response * bots: regenerate API docs and TypeScript types * simplex-chat-nodejs: add apiGetChats * support bot: avoid OOM on large databases apiListGroups / apiListContacts return every record in one response and overflow V8's string allocation on large DBs. Replace list-then-find-by-id patterns with apiGetChat(type, id, 0) lookups, and the one genuine scan (refreshAllCards) with paginated apiGetChats, count=1000. * support bot: update test assertions to match current message text * bots: simplify PaginationByTime, expose only PTLast * simplex-chat-nodejs: bump types and nodejs versions
This commit is contained in:
@@ -51,6 +51,7 @@ This file is generated automatically.
|
||||
[Chat commands](#chat-commands)
|
||||
- [APIListContacts](#apilistcontacts)
|
||||
- [APIListGroups](#apilistgroups)
|
||||
- [APIGetChats](#apigetchats)
|
||||
- [APIDeleteChat](#apideletechat)
|
||||
- [APISetGroupCustomData](#apisetgroupcustomdata)
|
||||
- [APISetContactCustomData](#apisetcontactcustomdata)
|
||||
@@ -1574,6 +1575,46 @@ ChatCmdError: Command error (only used in WebSockets API).
|
||||
---
|
||||
|
||||
|
||||
### APIGetChats
|
||||
|
||||
Get chat previews. Supports time-based pagination — use this instead of APIListContacts / APIListGroups when scanning at scale (those load every record into memory and fail on large databases).
|
||||
|
||||
*Network usage*: no.
|
||||
|
||||
**Parameters**:
|
||||
- userId: int64
|
||||
- pendingConnections: bool
|
||||
- pagination: [PaginationByTime](./TYPES.md#paginationbytime)
|
||||
- query: [ChatListQuery](./TYPES.md#chatlistquery)
|
||||
|
||||
**Syntax**:
|
||||
|
||||
```
|
||||
/_get chats <userId>[ pcc=on] <str(pagination)> <json(query)>
|
||||
```
|
||||
|
||||
```javascript
|
||||
'/_get chats ' + userId + (pendingConnections ? ' pcc=on' : '') + ' ' + PaginationByTime.cmdString(pagination) + ' ' + JSON.stringify(query) // JavaScript
|
||||
```
|
||||
|
||||
```python
|
||||
'/_get chats ' + str(userId) + (' pcc=on' if pendingConnections else '') + ' ' + str(pagination) + ' ' + json.dumps(query) # Python
|
||||
```
|
||||
|
||||
**Responses**:
|
||||
|
||||
ApiChats: Chat previews (paginated). Use this instead of CRContactsList / CRGroupsList when scanning at scale..
|
||||
- type: "apiChats"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chats: [[AChat](./TYPES.md#achat)]
|
||||
|
||||
ChatCmdError: Command error (only used in WebSockets API).
|
||||
- type: "chatCmdError"
|
||||
- chatError: [ChatError](./TYPES.md#chaterror)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### APIDeleteChat
|
||||
|
||||
Delete chat.
|
||||
|
||||
@@ -41,6 +41,7 @@ This file is generated automatically.
|
||||
- [ChatInfo](#chatinfo)
|
||||
- [ChatItem](#chatitem)
|
||||
- [ChatItemDeletion](#chatitemdeletion)
|
||||
- [ChatListQuery](#chatlistquery)
|
||||
- [ChatPeerType](#chatpeertype)
|
||||
- [ChatRef](#chatref)
|
||||
- [ChatSettings](#chatsettings)
|
||||
@@ -136,6 +137,7 @@ This file is generated automatically.
|
||||
- [NewUser](#newuser)
|
||||
- [NoteFolder](#notefolder)
|
||||
- [OwnerVerification](#ownerverification)
|
||||
- [PaginationByTime](#paginationbytime)
|
||||
- [PendingContactConnection](#pendingcontactconnection)
|
||||
- [PrefEnabled](#prefenabled)
|
||||
- [Preferences](#preferences)
|
||||
@@ -1327,6 +1329,22 @@ Message deletion result.
|
||||
- toChatItem: [AChatItem](#achatitem)?
|
||||
|
||||
|
||||
---
|
||||
|
||||
## ChatListQuery
|
||||
|
||||
**Discriminated union type**:
|
||||
|
||||
Filters:
|
||||
- type: "filters"
|
||||
- favorite: bool
|
||||
- unread: bool
|
||||
|
||||
Search:
|
||||
- type: "search"
|
||||
- search: string
|
||||
|
||||
|
||||
---
|
||||
|
||||
## ChatPeerType
|
||||
@@ -2893,6 +2911,31 @@ Failed:
|
||||
- reason: string
|
||||
|
||||
|
||||
---
|
||||
|
||||
## PaginationByTime
|
||||
|
||||
**Discriminated union type**:
|
||||
|
||||
Last:
|
||||
- type: "last"
|
||||
- count: int
|
||||
|
||||
**Syntax**:
|
||||
|
||||
```
|
||||
count=<count>
|
||||
```
|
||||
|
||||
```javascript
|
||||
'count=' + count // JavaScript
|
||||
```
|
||||
|
||||
```python
|
||||
'count=' + str(count) # Python
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
|
||||
## PendingContactConnection
|
||||
|
||||
Reference in New Issue
Block a user