Add toggleSessionCanAcceptCalls method.

This commit is contained in:
levlam 2021-11-24 17:59:17 +03:00
parent f41be864d0
commit 47d0195c85
6 changed files with 36 additions and 5 deletions

View File

@ -5375,6 +5375,9 @@ terminateSession session_id:int64 = Ok;
//@description Terminates all other sessions of the current user
terminateAllOtherSessions = Ok;
//@description Toggles whether a session can accept incoming calls @session_id Session identifier @can_accept_calls True, if incoming calls can be accepted by the session
toggleSessionCanAcceptCalls session_id:int64 can_accept_calls:Bool = Ok;
//@description Toggles whether a session can accept incoming secret chats @session_id Session identifier @can_accept_secret_chats True, if incoming secret chats can be accepted by the session
toggleSessionCanAcceptSecretChats session_id:int64 can_accept_secret_chats:Bool = Ok;

View File

@ -235,10 +235,17 @@ class ChangeAuthorizationSettingsQuery final : public Td::ResultHandler {
explicit ChangeAuthorizationSettingsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(int64 hash, bool encrypted_requests_disabled) {
int32 flags = telegram_api::account_changeAuthorizationSettings::ENCRYPTED_REQUESTS_DISABLED_MASK;
send_query(G()->net_query_creator().create(
telegram_api::account_changeAuthorizationSettings(flags, hash, encrypted_requests_disabled, false)));
void send(int64 hash, bool set_encrypted_requests_disabled, bool encrypted_requests_disabled,
bool set_call_requests_disabled, bool call_requests_disabled) {
int32 flags = 0;
if (set_encrypted_requests_disabled) {
flags |= telegram_api::account_changeAuthorizationSettings::ENCRYPTED_REQUESTS_DISABLED_MASK;
}
if (set_call_requests_disabled) {
flags |= telegram_api::account_changeAuthorizationSettings::CALL_REQUESTS_DISABLED_MASK;
}
send_query(G()->net_query_creator().create(telegram_api::account_changeAuthorizationSettings(
flags, hash, encrypted_requests_disabled, call_requests_disabled)));
}
void on_result(BufferSlice packet) final {
@ -419,9 +426,15 @@ void terminate_all_other_sessions(Td *td, Promise<Unit> &&promise) {
td->create_handler<ResetAuthorizationsQuery>(std::move(promise))->send();
}
void toggle_session_can_accept_calls(Td *td, int64 session_id, bool can_accept_calls, Promise<Unit> &&promise) {
td->create_handler<ChangeAuthorizationSettingsQuery>(std::move(promise))
->send(session_id, false, false, true, !can_accept_calls);
}
void toggle_session_can_accept_secret_chats(Td *td, int64 session_id, bool can_accept_secret_chats,
Promise<Unit> &&promise) {
td->create_handler<ChangeAuthorizationSettingsQuery>(std::move(promise))->send(session_id, !can_accept_secret_chats);
td->create_handler<ChangeAuthorizationSettingsQuery>(std::move(promise))
->send(session_id, true, !can_accept_secret_chats, false, false);
}
void set_inactive_session_ttl_days(Td *td, int32 authorization_ttl_days, Promise<Unit> &&promise) {

View File

@ -28,6 +28,8 @@ void terminate_session(Td *td, int64 session_id, Promise<Unit> &&promise);
void terminate_all_other_sessions(Td *td, Promise<Unit> &&promise);
void toggle_session_can_accept_calls(Td *td, int64 session_id, bool can_accept_calls, Promise<Unit> &&promise);
void toggle_session_can_accept_secret_chats(Td *td, int64 session_id, bool can_accept_secret_chats,
Promise<Unit> &&promise);

View File

@ -4789,6 +4789,12 @@ void Td::on_request(uint64 id, const td_api::terminateAllOtherSessions &request)
terminate_all_other_sessions(this, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleSessionCanAcceptCalls &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
toggle_session_can_accept_calls(this, request.session_id_, request.can_accept_calls_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleSessionCanAcceptSecretChats &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();

View File

@ -480,6 +480,8 @@ class Td final : public Actor {
void on_request(uint64 id, const td_api::terminateAllOtherSessions &request);
void on_request(uint64 id, const td_api::toggleSessionCanAcceptCalls &request);
void on_request(uint64 id, const td_api::toggleSessionCanAcceptSecretChats &request);
void on_request(uint64 id, const td_api::setInactiveSessionTtl &request);

View File

@ -2260,6 +2260,11 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::terminateSession>(to_integer<int64>(args)));
} else if (op == "TerminateAllOtherSessions") {
send_request(td_api::make_object<td_api::terminateAllOtherSessions>());
} else if (op == "tscac") {
int64 session_id;
bool can_accept_calls;
get_args(args, session_id, can_accept_calls);
send_request(td_api::make_object<td_api::toggleSessionCanAcceptCalls>(session_id, can_accept_calls));
} else if (op == "tscasc") {
int64 session_id;
bool can_accept_secret_chats;