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,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2023-06-05 00:30:48 +00:00
|
|
|
if (!res) {
|
2023-09-24 01:32:22 +03:00
|
|
|
throw new MtTypeAssertionError('help.acceptTermsOfService', 'true', 'false')
|
2023-06-05 00:30:48 +00:00
|
|
|
}
|
2021-04-08 12:19:38 +03:00
|
|
|
|
|
|
|
return true
|
|
|
|
}
|