From 6f622ccfd55b400405e03e6768c4ad140c40f102 Mon Sep 17 00:00:00 2001 From: Giuseppe Marino Date: Thu, 9 Jan 2025 20:58:56 +0100 Subject: [PATCH] Add is_fake flag to user and chat --- tdlight-api-openapi.yaml | 6 ++++++ telegram-bot-api/Client.cpp | 31 +++++++++++++++++++++++++++---- telegram-bot-api/Client.h | 2 ++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/tdlight-api-openapi.yaml b/tdlight-api-openapi.yaml index ce6d33e..305acde 100644 --- a/tdlight-api-openapi.yaml +++ b/tdlight-api-openapi.yaml @@ -9213,6 +9213,9 @@ components: is_scam: description: '*Optional*. Is the user reported for scam, clients show a warning to the user.' type: boolean + is_fake: + description: '*Optional*. Is the user marked as fake by Telegram.' + type: boolean required: - id - is_bot @@ -9281,6 +9284,9 @@ components: is_scam: description: '*Optional*. Is the chat reported for scam, clients show a warning to the user.' type: boolean + is_fake: + description: '*Optional*. Is the chat marked as fake by Telegram.' + type: boolean distance: description: '*Optional*. Distance to the chat location in meters. Returned only in `getChatsNearby`.' type: integer diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 60fb8e3..fde4cbc 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -491,6 +491,9 @@ class Client::JsonUser final : public td::Jsonable { if (user_info != nullptr && user_info->is_scam) { object("is_scam", td::JsonBool(user_info->is_scam)); } + if (user_info != nullptr && user_info->is_fake) { + object("is_fake", td::JsonBool(user_info->is_fake)); + } if (user_info != nullptr) { json_store_user_status(object, user_info->status.get()); } @@ -1053,6 +1056,9 @@ class Client::JsonChat final : public td::Jsonable { if (user_info->is_scam) { object("is_scam", td::JsonBool(user_info->is_scam)); } + if (user_info->is_fake) { + object("is_fake", td::JsonBool(user_info->is_fake)); + } json_store_user_status(object, user_info->status.get()); // end custom properties impl @@ -1145,6 +1151,9 @@ class Client::JsonChat final : public td::Jsonable { if (supergroup_info->is_scam) { object("is_scam", td::JsonBool(supergroup_info->is_scam)); } + if (supergroup_info->is_fake) { + object("is_fake", td::JsonBool(supergroup_info->is_fake)); + } // end custom properties impl if (is_full_) { @@ -14686,8 +14695,15 @@ void Client::add_user(UserInfo *user_info, object_ptr &&user) { user_info->language_code = std::move(user->language_code_); // start custom properties - user_info->is_verified = user->verification_status_->is_verified_; - user_info->is_scam = user->verification_status_->is_scam_; + if (user->verification_status_ == nullptr) { + user_info->is_verified = false; + user_info->is_scam = false; + user_info->is_fake = false; + } else { + user_info->is_verified = user->verification_status_->is_verified_; + user_info->is_scam = user->verification_status_->is_scam_; + user_info->is_fake = user->verification_status_->is_fake_; + } user_info->status = std::move(user->status_); //end custom properties @@ -14777,8 +14793,15 @@ void Client::add_supergroup(SupergroupInfo *supergroup_info, object_ptrjoin_by_request = supergroup->join_by_request_; // start custom properties - supergroup_info->is_verified = supergroup->verification_status_->is_verified_; - supergroup_info->is_scam = supergroup->verification_status_->is_scam_; + if (supergroup->verification_status_ == nullptr) { + supergroup_info->is_verified = false; + supergroup_info->is_scam = false; + supergroup_info->is_fake = false; + } else { + supergroup_info->is_verified = supergroup->verification_status_->is_verified_; + supergroup_info->is_scam = supergroup->verification_status_->is_scam_; + supergroup_info->is_fake = supergroup->verification_status_->is_fake_; + } // end custom properties } diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index bde8235..a419ba3 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -968,6 +968,7 @@ class Client final : public WebhookActor::Callback { // start custom properties bool is_verified = false; bool is_scam = false; + bool is_fake = false; object_ptr status; // end custom properties @@ -1030,6 +1031,7 @@ class Client final : public WebhookActor::Callback { // start custom properties bool is_verified = false; bool is_scam = false; + bool is_fake = false; // end custom properties }; static void add_supergroup(SupergroupInfo *supergroup_info, object_ptr &&supergroup);