From f8525043012d3561ad8fc16e5bfcf94e52f1db47 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 19 Mar 2024 16:07:43 +0300 Subject: [PATCH] Store td_api::businessInfo in UserInfo. --- telegram-bot-api/Client.cpp | 31 ++++++++++++------------------- telegram-bot-api/Client.h | 4 +--- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index f5a721a..8d132a7 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -935,14 +935,17 @@ class Client::JsonChat final : public td::Jsonable { if (user_info->has_restricted_voice_and_video_messages) { object("has_restricted_voice_and_video_messages", td::JsonTrue()); } - if (user_info->business_intro != nullptr) { - object("business_intro", JsonBusinessIntro(user_info->business_intro.get(), client_)); - } - if (user_info->business_location != nullptr) { - object("business_location", JsonBusinessLocation(user_info->business_location.get())); - } - if (user_info->business_opening_hours != nullptr) { - object("business_opening_hours", JsonBusinessOpeningHours(user_info->business_opening_hours.get())); + if (user_info->business_info != nullptr) { + auto business_info = user_info->business_info.get(); + if (business_info->intro_ != nullptr) { + object("business_intro", JsonBusinessIntro(business_info->intro_.get(), client_)); + } + if (business_info->location_ != nullptr) { + object("business_location", JsonBusinessLocation(business_info->location_.get())); + } + if (business_info->opening_hours_ != nullptr) { + object("business_opening_hours", JsonBusinessOpeningHours(business_info->opening_hours_.get())); + } } } photo = user_info->photo.get(); @@ -6423,17 +6426,7 @@ void Client::on_update(object_ptr result) { user_info->photo = full_info->photo_ == nullptr ? std::move(full_info->public_photo_) : std::move(full_info->photo_); user_info->bio = full_info->bio_ != nullptr ? std::move(full_info->bio_->text_) : td::string(); - user_info->business_intro = full_info->business_info_ != nullptr && full_info->business_info_->intro_ != nullptr - ? std::move(full_info->business_info_->intro_) - : nullptr; - user_info->business_location = - full_info->business_info_ != nullptr && full_info->business_info_->location_ != nullptr - ? std::move(full_info->business_info_->location_) - : nullptr; - user_info->business_opening_hours = - full_info->business_info_ != nullptr && full_info->business_info_->opening_hours_ != nullptr - ? std::move(full_info->business_info_->opening_hours_) - : nullptr; + user_info->business_info = std::move(full_info->business_info_); user_info->has_private_forwards = full_info->has_private_forwards_; user_info->has_restricted_voice_and_video_messages = full_info->has_restricted_voice_and_video_note_messages_; break; diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 4b235f6..6ddd4fb 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -798,9 +798,7 @@ class Client final : public WebhookActor::Callback { object_ptr photo; td::string bio; - object_ptr business_intro; - object_ptr business_location; - object_ptr business_opening_hours; + object_ptr business_info; bool have_access = false; bool can_join_groups = false;