Add reload_chat/reload_channel methods.

GitOrigin-RevId: 82f650328672dcde337f692d986a338e48711d91
This commit is contained in:
levlam 2019-01-15 01:38:17 +03:00
parent 303a006fb3
commit 6f813b25ac
2 changed files with 28 additions and 1 deletions

View File

@ -8474,7 +8474,7 @@ std::pair<int32, vector<const Photo *>> ContactsManager::get_user_profile_photos
void ContactsManager::reload_user_profile_photo(UserId user_id, int64 photo_id, Promise<Unit> &&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<Unit> &&p
return true;
}
void ContactsManager::reload_chat(ChatId chat_id, Promise<Unit> &&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<GetChatsQuery>(std::move(promise))->send(vector<int32>{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<Unit> &&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<GetChannelsQuery>(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()) {

View File

@ -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<Unit> &&promise);
void reload_chat(ChatId chat_id, Promise<Unit> &&promise);
bool get_chat_full(ChatId chat_id, Promise<Unit> &&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<Unit> &&promise);
void reload_channel(ChannelId chnanel_id, Promise<Unit> &&promise);
bool get_channel_full(ChannelId channel_id, Promise<Unit> &&promise);
bool have_secret_chat(SecretChatId secret_chat_id) const;