Add ContactsManager::get_dialog_id.
This commit is contained in:
parent
f2dead72ca
commit
68ad0b4317
@ -8388,6 +8388,14 @@ ChannelId ContactsManager::get_channel_id(const tl_object_ptr<telegram_api::Chat
|
||||
}
|
||||
}
|
||||
|
||||
DialogId ContactsManager::get_dialog_id(const tl_object_ptr<telegram_api::Chat> &chat) {
|
||||
auto channel_id = get_channel_id(chat);
|
||||
if (channel_id.is_valid()) {
|
||||
return DialogId(channel_id);
|
||||
}
|
||||
return DialogId(get_chat_id(chat));
|
||||
}
|
||||
|
||||
void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr, const char *source, bool is_me,
|
||||
bool expect_support) {
|
||||
LOG(DEBUG) << "Receive from " << source << ' ' << to_string(user_ptr);
|
||||
|
@ -78,6 +78,7 @@ class ContactsManager final : public Actor {
|
||||
static UserId get_user_id(const tl_object_ptr<telegram_api::User> &user);
|
||||
static ChatId get_chat_id(const tl_object_ptr<telegram_api::Chat> &chat);
|
||||
static ChannelId get_channel_id(const tl_object_ptr<telegram_api::Chat> &chat);
|
||||
static DialogId get_dialog_id(const tl_object_ptr<telegram_api::Chat> &chat);
|
||||
|
||||
Result<tl_object_ptr<telegram_api::InputUser>> get_input_user(UserId user_id) const;
|
||||
|
||||
|
@ -1194,19 +1194,12 @@ vector<DialogId> UpdatesManager::get_chat_dialog_ids(const telegram_api::Updates
|
||||
vector<DialogId> dialog_ids;
|
||||
dialog_ids.reserve(chats->size());
|
||||
for (const auto &chat : *chats) {
|
||||
auto chat_id = ContactsManager::get_chat_id(chat);
|
||||
if (chat_id.is_valid()) {
|
||||
dialog_ids.push_back(DialogId(chat_id));
|
||||
continue;
|
||||
auto dialog_id = ContactsManager::get_dialog_id(chat);
|
||||
if (dialog_id.is_valid()) {
|
||||
dialog_ids.push_back(dialog_id);
|
||||
} else {
|
||||
LOG(ERROR) << "Can't find identifier of " << oneline(to_string(chat));
|
||||
}
|
||||
|
||||
auto channel_id = ContactsManager::get_channel_id(chat);
|
||||
if (channel_id.is_valid()) {
|
||||
dialog_ids.push_back(DialogId(channel_id));
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Can't find identifier of " << oneline(to_string(chat));
|
||||
}
|
||||
return dialog_ids;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user