Minor SessionType improvements.
This commit is contained in:
parent
76d687e62d
commit
3886cc9c13
@ -3283,55 +3283,55 @@ accountTtl days:int32 = AccountTtl;
|
|||||||
|
|
||||||
//@class SessionType @description Represents the type of a session
|
//@class SessionType @description Represents the type of a session
|
||||||
|
|
||||||
//@description This session is running on an Android device
|
//@description The session is running on an Android device
|
||||||
sessionTypeAndroid = SessionType;
|
sessionTypeAndroid = SessionType;
|
||||||
|
|
||||||
//@description This session is running on a generic Apple device
|
//@description The session is running on a generic Apple device
|
||||||
sessionTypeApple = SessionType;
|
sessionTypeApple = SessionType;
|
||||||
|
|
||||||
//@description This session is running on the Brave browser
|
//@description The session is running on the Brave browser
|
||||||
sessionTypeBrave = SessionType;
|
sessionTypeBrave = SessionType;
|
||||||
|
|
||||||
//@description This session is running on the Chrome browser
|
//@description The session is running on the Chrome browser
|
||||||
sessionTypeChrome = SessionType;
|
sessionTypeChrome = SessionType;
|
||||||
|
|
||||||
//@description This session is running on the Edge browser
|
//@description The session is running on the Edge browser
|
||||||
sessionTypeEdge = SessionType;
|
sessionTypeEdge = SessionType;
|
||||||
|
|
||||||
//@description This session is running on the Firefox browser
|
//@description The session is running on the Firefox browser
|
||||||
sessionTypeFirefox = SessionType;
|
sessionTypeFirefox = SessionType;
|
||||||
|
|
||||||
//@description This session is running on an iPad device
|
//@description The session is running on an iPad device
|
||||||
sessionTypeIpad = SessionType;
|
sessionTypeIpad = SessionType;
|
||||||
|
|
||||||
//@description This session is running on an iPhone device
|
//@description The session is running on an iPhone device
|
||||||
sessionTypeIphone = SessionType;
|
sessionTypeIphone = SessionType;
|
||||||
|
|
||||||
//@description This session is running on a Linux device
|
//@description The session is running on a Linux device
|
||||||
sessionTypeLinux = SessionType;
|
sessionTypeLinux = SessionType;
|
||||||
|
|
||||||
//@description This session is running on a Mac device
|
//@description The session is running on a Mac device
|
||||||
sessionTypeMac = SessionType;
|
sessionTypeMac = SessionType;
|
||||||
|
|
||||||
//@description This session is running on the Opera browser
|
//@description The session is running on the Opera browser
|
||||||
sessionTypeOpera = SessionType;
|
sessionTypeOpera = SessionType;
|
||||||
|
|
||||||
//@description This session is running on the Safari browser
|
//@description The session is running on the Safari browser
|
||||||
sessionTypeSafari = SessionType;
|
sessionTypeSafari = SessionType;
|
||||||
|
|
||||||
//@description This session is running on an Ubuntu device
|
//@description The session is running on an Ubuntu device
|
||||||
sessionTypeUbuntu = SessionType;
|
sessionTypeUbuntu = SessionType;
|
||||||
|
|
||||||
//@description This session is running on an unknown type of device
|
//@description The session is running on an unknown type of device
|
||||||
sessionTypeUnknown = SessionType;
|
sessionTypeUnknown = SessionType;
|
||||||
|
|
||||||
//@description This session is running on the Vivaldi browser
|
//@description The session is running on the Vivaldi browser
|
||||||
sessionTypeVivaldi = SessionType;
|
sessionTypeVivaldi = SessionType;
|
||||||
|
|
||||||
//@description This session is running on a Windows device
|
//@description The session is running on a Windows device
|
||||||
sessionTypeWindows = SessionType;
|
sessionTypeWindows = SessionType;
|
||||||
|
|
||||||
//@description This session is running on a Xbox console
|
//@description The session is running on an Xbox console
|
||||||
sessionTypeXbox = SessionType;
|
sessionTypeXbox = SessionType;
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
static td_api::object_ptr<td_api::SessionType> get_session_type(
|
static td_api::object_ptr<td_api::SessionType> get_session_type_object(
|
||||||
const tl_object_ptr<telegram_api::authorization> &authorization) {
|
const tl_object_ptr<telegram_api::authorization> &authorization) {
|
||||||
auto contains = [](const string &str, const char *substr) {
|
auto contains = [](const string &str, const char *substr) {
|
||||||
return str.find(substr) != string::npos;
|
return str.find(substr) != string::npos;
|
||||||
@ -43,8 +43,8 @@ static td_api::object_ptr<td_api::SessionType> get_session_type(
|
|||||||
return td_api::make_object<td_api::sessionTypeXbox>();
|
return td_api::make_object<td_api::sessionTypeXbox>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool web = [&] {
|
bool is_web = [&] {
|
||||||
Slice web_name("Web");
|
CSlice web_name("Web");
|
||||||
auto pos = app_name.find(web_name.c_str());
|
auto pos = app_name.find(web_name.c_str());
|
||||||
if (pos == string::npos) {
|
if (pos == string::npos) {
|
||||||
return false;
|
return false;
|
||||||
@ -54,7 +54,7 @@ static td_api::object_ptr<td_api::SessionType> get_session_type(
|
|||||||
return !('a' <= next_character && next_character <= 'z');
|
return !('a' <= next_character && next_character <= 'z');
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (web) {
|
if (is_web) {
|
||||||
if (contains(device_model, "brave")) {
|
if (contains(device_model, "brave")) {
|
||||||
return td_api::make_object<td_api::sessionTypeBrave>();
|
return td_api::make_object<td_api::sessionTypeBrave>();
|
||||||
} else if (contains(device_model, "vivaldi")) {
|
} else if (contains(device_model, "vivaldi")) {
|
||||||
@ -82,15 +82,15 @@ static td_api::object_ptr<td_api::SessionType> get_session_type(
|
|||||||
return td_api::make_object<td_api::sessionTypeLinux>();
|
return td_api::make_object<td_api::sessionTypeLinux>();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ios = begins_with(platform, "ios") || contains(system_version, "ios");
|
auto is_ios = begins_with(platform, "ios") || contains(system_version, "ios");
|
||||||
auto macos = begins_with(platform, "macos") || contains(system_version, "macos");
|
auto is_macos = begins_with(platform, "macos") || contains(system_version, "macos");
|
||||||
if (ios && contains(device_model, "iphone")) {
|
if (is_ios && contains(device_model, "iphone")) {
|
||||||
return td_api::make_object<td_api::sessionTypeIphone>();
|
return td_api::make_object<td_api::sessionTypeIphone>();
|
||||||
} else if (ios && contains(device_model, "ipad")) {
|
} else if (is_ios && contains(device_model, "ipad")) {
|
||||||
return td_api::make_object<td_api::sessionTypeIpad>();
|
return td_api::make_object<td_api::sessionTypeIpad>();
|
||||||
} else if (macos && contains(device_model, "mac")) {
|
} else if (is_macos && contains(device_model, "mac")) {
|
||||||
return td_api::make_object<td_api::sessionTypeMac>();
|
return td_api::make_object<td_api::sessionTypeMac>();
|
||||||
} else if (ios || macos) {
|
} else if (is_ios || is_macos) {
|
||||||
return td_api::make_object<td_api::sessionTypeApple>();
|
return td_api::make_object<td_api::sessionTypeApple>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,10 +103,10 @@ static td_api::object_ptr<td_api::session> convert_authorization_object(
|
|||||||
return td_api::make_object<td_api::session>(
|
return td_api::make_object<td_api::session>(
|
||||||
authorization->hash_, authorization->current_, authorization->password_pending_,
|
authorization->hash_, authorization->current_, authorization->password_pending_,
|
||||||
!authorization->encrypted_requests_disabled_, !authorization->call_requests_disabled_,
|
!authorization->encrypted_requests_disabled_, !authorization->call_requests_disabled_,
|
||||||
get_session_type(authorization), authorization->api_id_, authorization->app_name_,
|
get_session_type_object(authorization), authorization->api_id_, authorization->app_name_,
|
||||||
authorization->app_version_, authorization->official_app_, authorization->device_model_,
|
authorization->app_version_, authorization->official_app_, authorization->device_model_, authorization->platform_,
|
||||||
authorization->platform_, authorization->system_version_, authorization->date_created_,
|
authorization->system_version_, authorization->date_created_, authorization->date_active_, authorization->ip_,
|
||||||
authorization->date_active_, authorization->ip_, authorization->country_, authorization->region_);
|
authorization->country_, authorization->region_);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SetAccountTtlQuery final : public Td::ResultHandler {
|
class SetAccountTtlQuery final : public Td::ResultHandler {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user