mtcute/packages/client/src/methods/auth/accept-tos.ts

26 lines
546 B
TypeScript
Raw Normal View History

2023-09-22 15:32:28 +03:00
import { MtTypeAssertionError } from '@mtcute/core'
2021-04-08 12:19:38 +03:00
import { TelegramClient } from '../../client'
/**
* Accept the given TOS
*
* @param tosId TOS id
* @internal
*/
2023-09-24 01:32:22 +03:00
export async function acceptTos(this: TelegramClient, tosId: string): Promise<boolean> {
2021-04-08 12:19:38 +03:00
const res = await this.call({
_: 'help.acceptTermsOfService',
id: {
_: 'dataJSON',
data: tosId,
},
})
if (!res) {
2023-09-24 01:32:22 +03:00
throw new MtTypeAssertionError('help.acceptTermsOfService', 'true', 'false')
}
2021-04-08 12:19:38 +03:00
return true
}