diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 1893c284..901faf72 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2032,7 +2032,8 @@ userPrivacySettingAllowPeerToPeerCalls = UserPrivacySetting; accountTtl days:int32 = AccountTtl; -//@description Contains information about one session in a Telegram application used by the current user @id Session identifier @is_current True, if this session is the current session +//@description Contains information about one session in a Telegram application used by the current user. Sessions should be shown to the user in the returned order +//@id Session identifier @is_current True, if this session is the current session //@is_password_pending True, if a password is needed to complete authorization of the session //@api_id Telegram API identifier, as provided by the application @application_name Name of the application, as provided by the application //@application_version The version of the application, as provided by the application @is_official_application True, if the application is an official application or uses the api_id of an official application diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index f55d1ad8..70ba1ea1 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -152,6 +152,17 @@ class GetAuthorizationsQuery : public Td::ResultHandler { authorization->country_, authorization->region_)); } + std::sort(results->sessions_.begin(), results->sessions_.end(), + [](const td_api::object_ptr &lhs, const td_api::object_ptr &rhs) { + if (lhs->is_current_ != rhs->is_current_) { + return lhs->is_current_; + } + if (lhs->is_password_pending_ != rhs->is_password_pending_) { + return lhs->is_password_pending_; + } + return lhs->last_active_date_ > rhs->last_active_date_; + }); + promise_.set_value(std::move(results)); }