From 6f813b25ac5aa3a4b064ac9092903c9adcf558e4 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 15 Jan 2019 01:38:17 +0300 Subject: [PATCH] Add reload_chat/reload_channel methods. GitOrigin-RevId: 82f650328672dcde337f692d986a338e48711d91 --- td/telegram/ContactsManager.cpp | 27 ++++++++++++++++++++++++++- td/telegram/ContactsManager.h | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 090fbd12..2304e837 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -8474,7 +8474,7 @@ std::pair> ContactsManager::get_user_profile_photos void ContactsManager::reload_user_profile_photo(UserId user_id, int64 photo_id, Promise &&promise) { auto input_user = get_input_user(user_id); if (input_user == nullptr) { - return promise.set_error(Status::Error(6, "User not found")); + return promise.set_error(Status::Error(6, "User info not found")); } // this request will be needed only to download the photo, @@ -8535,6 +8535,16 @@ bool ContactsManager::get_chat(ChatId chat_id, int left_tries, Promise &&p return true; } +void ContactsManager::reload_chat(ChatId chat_id, Promise &&promise) { + if (!chat_id.is_valid()) { + return promise.set_error(Status::Error(6, "Invalid basic group id")); + } + + // this request will be needed only to download the chat photo, + // so there is no reason to combine different requests into one request + td_->create_handler(std::move(promise))->send(vector{chat_id.get()}); +} + const ContactsManager::ChatFull *ContactsManager::get_chat_full(ChatId chat_id) const { auto p = chats_full_.find(chat_id); if (p == chats_full_.end()) { @@ -8794,6 +8804,21 @@ bool ContactsManager::get_channel(ChannelId channel_id, int left_tries, Promise< return true; } +void ContactsManager::reload_channel(ChannelId channel_id, Promise &&promise) { + if (!channel_id.is_valid()) { + return promise.set_error(Status::Error(6, "Invalid supergroup id")); + } + + auto input_channel = get_input_channel(channel_id); + if (input_channel == nullptr) { + return promise.set_error(Status::Error(6, "Supergroup info not found")); + } + + // this request will be needed only to download the channel photo, + // so there is no reason to combine different requests into one request + td_->create_handler(std::move(promise))->send(std::move(input_channel)); +} + const ContactsManager::ChannelFull *ContactsManager::get_channel_full(ChannelId channel_id) const { auto p = channels_full_.find(channel_id); if (p == channels_full_.end()) { diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index bb3cbc7c..039ad185 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -365,6 +365,7 @@ class ContactsManager : public Actor { bool have_chat(ChatId chat_id) const; bool have_chat_force(ChatId chat_id); bool get_chat(ChatId chat_id, int left_tries, Promise &&promise); + void reload_chat(ChatId chat_id, Promise &&promise); bool get_chat_full(ChatId chat_id, Promise &&promise); bool get_chat_is_active(ChatId chat_id) const; @@ -375,6 +376,7 @@ class ContactsManager : public Actor { bool have_min_channel(ChannelId channel_id) const; bool have_channel_force(ChannelId channel_id); bool get_channel(ChannelId channel_id, int left_tries, Promise &&promise); + void reload_channel(ChannelId chnanel_id, Promise &&promise); bool get_channel_full(ChannelId channel_id, Promise &&promise); bool have_secret_chat(SecretChatId secret_chat_id) const;