34 lines
1 KiB
TypeScript
34 lines
1 KiB
TypeScript
|
import { TelegramClient } from '../../client'
|
||
|
import { ChatInviteLink, InputPeerLike } from '../../types'
|
||
|
import { createUsersChatsIndex, normalizeToInputPeer } from '../../utils/peer-utils'
|
||
|
|
||
|
/**
|
||
|
* Revoke an invite link.
|
||
|
*
|
||
|
* If `link` is a primary invite link, a new invite link will be
|
||
|
* generated automatically by Telegram
|
||
|
*
|
||
|
* @param chatId Chat ID
|
||
|
* @param link Invite link to revoke
|
||
|
* @returns If `link` is a primary invite, newly generated invite link, otherwise the revoked link
|
||
|
* @internal
|
||
|
*/
|
||
|
export async function revokeInviteLink(
|
||
|
this: TelegramClient,
|
||
|
chatId: InputPeerLike,
|
||
|
link: string
|
||
|
): Promise<ChatInviteLink> {
|
||
|
const res = await this.call({
|
||
|
_: 'messages.editExportedChatInvite',
|
||
|
peer: normalizeToInputPeer(await this.resolvePeer(chatId)),
|
||
|
link,
|
||
|
revoked: true
|
||
|
})
|
||
|
|
||
|
const { users } = createUsersChatsIndex(res)
|
||
|
|
||
|
const invite = res._ === 'messages.exportedChatInviteReplaced' ? res.newInvite : res.invite
|
||
|
|
||
|
return new ChatInviteLink(this, invite, users)
|
||
|
}
|