2021-04-10 20:30:28 +03:00
|
|
|
import { TelegramClient } from '../../client'
|
|
|
|
import { MaybeArray } from '@mtcute/core'
|
|
|
|
import { InputPeerLike } from '../../types'
|
|
|
|
import { tl } from '@mtcute/tl'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Archive one or more chats
|
|
|
|
*
|
|
|
|
* @param chats Chat ID(s), username(s), phone number(s), `"me"` or `"self"`
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
export async function archiveChats(
|
|
|
|
this: TelegramClient,
|
|
|
|
chats: MaybeArray<InputPeerLike>
|
|
|
|
): Promise<void> {
|
|
|
|
if (!Array.isArray(chats)) chats = [chats]
|
|
|
|
|
|
|
|
const folderPeers: tl.TypeInputFolderPeer[] = []
|
|
|
|
|
|
|
|
for (const chat of chats) {
|
|
|
|
folderPeers.push({
|
|
|
|
_: 'inputFolderPeer',
|
2021-05-15 20:25:59 +03:00
|
|
|
peer: await this.resolvePeer(chat),
|
2021-04-10 20:30:28 +03:00
|
|
|
folderId: 1
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-04-24 16:23:30 +03:00
|
|
|
const updates = await this.call({
|
2021-04-10 20:30:28 +03:00
|
|
|
_: 'folders.editPeerFolders',
|
|
|
|
folderPeers
|
|
|
|
})
|
2021-04-24 16:23:30 +03:00
|
|
|
this._handleUpdate(updates)
|
2021-04-10 20:30:28 +03:00
|
|
|
}
|