From d3300e9ba3a8142419ee312a83cf9f35b79ca254 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sat, 3 Feb 2024 11:45:24 +0100 Subject: [PATCH] Rebase: Support channel emoji status. --- td | 2 +- telegram-bot-api/Client.cpp | 28 ++++++++++++++++++++-------- telegram-bot-api/Client.h | 4 ++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/td b/td index 27c3eae..9184b3e 160000 --- a/td +++ b/td @@ -1 +1 @@ -Subproject commit 27c3eaeb4964bd5f18d8488e354abde1a4383e49 +Subproject commit 9184b3e62de59663a59d3500528aee7e5f0d83fa diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 8c27f53..e493b6c 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -844,12 +844,6 @@ class Client::JsonChat final : public td::Jsonable { object("active_usernames", td::json_array(user_info->active_usernames, [](td::Slice username) { return td::JsonString(username); })); } - if (user_info->emoji_status_custom_emoji_id != 0) { - object("emoji_status_custom_emoji_id", td::to_string(user_info->emoji_status_custom_emoji_id)); - if (user_info->emoji_status_expiration_date != 0) { - object("emoji_status_expiration_date", user_info->emoji_status_expiration_date); - } - } if (!user_info->bio.empty()) { object("bio", user_info->bio); } @@ -1016,6 +1010,12 @@ class Client::JsonChat final : public td::Jsonable { if (chat_info->message_auto_delete_time != 0) { object("message_auto_delete_time", chat_info->message_auto_delete_time); } + if (chat_info->emoji_status_custom_emoji_id != 0) { + object("emoji_status_custom_emoji_id", td::to_string(chat_info->emoji_status_custom_emoji_id)); + if (chat_info->emoji_status_expiration_date != 0) { + object("emoji_status_expiration_date", chat_info->emoji_status_expiration_date); + } + } if (chat_info->available_reactions != nullptr) { object("available_reactions", td::json_array(chat_info->available_reactions->reactions_, @@ -6678,6 +6678,10 @@ void Client::on_update(object_ptr result) { chat_info->photo_info = std::move(chat->photo_); chat_info->permissions = std::move(chat->permissions_); chat_info->message_auto_delete_time = chat->message_auto_delete_time_; + chat_info->emoji_status_custom_emoji_id = + chat->emoji_status_ != nullptr ? chat->emoji_status_->custom_emoji_id_ : 0; + chat_info->emoji_status_expiration_date = + chat->emoji_status_ != nullptr ? chat->emoji_status_->expiration_date_ : 0; if (chat->available_reactions_->get_id() == td_api::chatAvailableReactionsSome::ID) { chat_info->available_reactions = move_object_as(chat->available_reactions_); } @@ -6716,6 +6720,16 @@ void Client::on_update(object_ptr result) { chat_info->message_auto_delete_time = update->message_auto_delete_time_; break; } + case td_api::updateChatEmojiStatus::ID: { + auto update = move_object_as(result); + auto chat_info = add_chat(update->chat_id_); + CHECK(chat_info->type != ChatInfo::Type::Unknown); + chat_info->emoji_status_custom_emoji_id = + update->emoji_status_ != nullptr ? update->emoji_status_->custom_emoji_id_ : 0; + chat_info->emoji_status_expiration_date = + update->emoji_status_ != nullptr ? update->emoji_status_->expiration_date_ : 0; + break; + } case td_api::updateChatAvailableReactions::ID: { auto update = move_object_as(result); auto chat_info = add_chat(update->chat_id_); @@ -12852,8 +12866,6 @@ void Client::add_user(UserInfo *user_info, object_ptr &&user) { user_info->editable_username = std::move(user->usernames_->editable_username_); } user_info->language_code = std::move(user->language_code_); - user_info->emoji_status_custom_emoji_id = user->emoji_status_ != nullptr ? user->emoji_status_->custom_emoji_id_ : 0; - user_info->emoji_status_expiration_date = user->emoji_status_ != nullptr ? user->emoji_status_->expiration_date_ : 0; // start custom properties user_info->is_verified = user->is_verified_; diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index a863d72..f2975d7 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -871,8 +871,6 @@ class Client final : public WebhookActor::Callback { td::vector active_usernames; td::string editable_username; td::string language_code; - int64 emoji_status_custom_emoji_id; - int32 emoji_status_expiration_date; object_ptr photo; td::string bio; @@ -948,6 +946,8 @@ class Client final : public WebhookActor::Callback { Type type = Type::Unknown; td::string title; int32 message_auto_delete_time = 0; + int64 emoji_status_custom_emoji_id = 0; + int32 emoji_status_expiration_date = 0; int32 accent_color_id = -1; int32 profile_accent_color_id = -1; int64 background_custom_emoji_id = 0;