Add inactive_sessions_ttl_days.

This commit is contained in:
levlam 2021-11-16 15:39:55 +03:00
parent 526e7dc631
commit b940d2e208
2 changed files with 10 additions and 4 deletions

View File

@ -3110,8 +3110,8 @@ accountTtl days:int32 = AccountTtl;
//@country A two-letter country code for the country from which the session was created, based on the IP address @region Region code from which the session was created, based on the IP address
session id:int64 is_current:Bool is_password_pending:Bool can_accept_secret_chats:Bool api_id:int32 application_name:string application_version:string is_official_application:Bool device_model:string platform:string system_version:string log_in_date:int32 last_active_date:int32 ip:string country:string region:string = Session;
//@description Contains a list of sessions @sessions List of sessions
sessions sessions:vector<session> = Sessions;
//@description Contains a list of sessions @sessions List of sessions @inactive_sessions_ttl_days Number of days of inactivity before sessions will be automatically terminated; 1-366 days
sessions sessions:vector<session> inactive_sessions_ttl_days:int32 = Sessions;
//@description Contains information about one website the current user is logged in with Telegram

View File

@ -146,8 +146,14 @@ class GetAuthorizationsQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetAuthorizationsQuery: " << to_string(ptr);
auto results =
td_api::make_object<td_api::sessions>(transform(std::move(ptr->authorizations_), convert_authorization_object));
auto ttl_days = ptr->authorization_ttl_days_;
if (ttl_days <= 0 || ttl_days > 366) {
LOG(ERROR) << "Receive invalid inactive sessions TTL " << ttl_days;
ttl_days = 180;
}
auto results = td_api::make_object<td_api::sessions>(
transform(std::move(ptr->authorizations_), convert_authorization_object), ttl_days);
std::sort(results->sessions_.begin(), results->sessions_.end(),
[](const td_api::object_ptr<td_api::session> &lhs, const td_api::object_ptr<td_api::session> &rhs) {
if (lhs->is_current_ != rhs->is_current_) {