From e491a5a31dfb88ed8595e1535069e08835283678 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 22 Mar 2024 13:37:31 +0300 Subject: [PATCH] Add more fields to ChatShared. --- telegram-bot-api/Client.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index a5d4935..549e87d 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -2121,16 +2121,28 @@ class Client::JsonUsersShared final : public td::Jsonable { class Client::JsonChatShared final : public td::Jsonable { public: - explicit JsonChatShared(const td_api::messageChatShared *chat_shared) : chat_shared_(chat_shared) { + JsonChatShared(const td_api::messageChatShared *chat_shared, const Client *client) + : chat_shared_(chat_shared), client_(client) { } void store(td::JsonValueScope *scope) const { auto object = scope->enter_object(); - object("chat_id", chat_shared_->chat_->chat_id_); + auto *shared_chat = chat_shared_->chat_.get(); + object("chat_id", shared_chat->chat_id_); + if (!shared_chat->title_.empty()) { + object("title", shared_chat->title_); + } + if (!shared_chat->username_.empty()) { + object("username", shared_chat->username_); + } + if (shared_chat->photo_ != nullptr) { + object("photo", JsonPhoto(shared_chat->photo_.get(), client_)); + } object("request_id", chat_shared_->button_id_); } private: const td_api::messageChatShared *chat_shared_; + const Client *client_; }; class Client::JsonGiveaway final : public td::Jsonable { @@ -2959,7 +2971,7 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const { } case td_api::messageChatShared::ID: { auto content = static_cast(message_->content.get()); - object("chat_shared", JsonChatShared(content)); + object("chat_shared", JsonChatShared(content, client_)); break; } case td_api::messageStory::ID: {