2021-04-08 12:19:38 +03:00
|
|
|
import { TelegramClient } from '../../client'
|
2021-08-05 20:38:24 +03:00
|
|
|
import { MtTypeAssertionError } from '../../types'
|
2021-04-08 12:19:38 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Accept the given TOS
|
|
|
|
*
|
|
|
|
* @param tosId TOS id
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
export async function acceptTos(
|
|
|
|
this: TelegramClient,
|
2023-06-05 00:30:48 +00:00
|
|
|
tosId: string,
|
2021-04-08 12:19:38 +03:00
|
|
|
): Promise<boolean> {
|
|
|
|
const res = await this.call({
|
|
|
|
_: 'help.acceptTermsOfService',
|
|
|
|
id: {
|
|
|
|
_: 'dataJSON',
|
|
|
|
data: tosId,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2023-06-05 00:30:48 +00:00
|
|
|
if (!res) {
|
2021-08-05 20:38:24 +03:00
|
|
|
throw new MtTypeAssertionError(
|
2021-05-12 18:16:50 +03:00
|
|
|
'help.acceptTermsOfService',
|
2021-04-08 12:19:38 +03:00
|
|
|
'true',
|
2023-06-05 00:30:48 +00:00
|
|
|
'false',
|
2021-04-08 12:19:38 +03:00
|
|
|
)
|
2023-06-05 00:30:48 +00:00
|
|
|
}
|
2021-04-08 12:19:38 +03:00
|
|
|
|
|
|
|
return true
|
|
|
|
}
|