Fix get_input_peer for bots.

This commit is contained in:
levlam 2023-03-27 12:02:39 +03:00
parent 46a76fa9a8
commit 007e3d8d11

View File

@ -5362,15 +5362,12 @@ bool ContactsManager::have_input_peer_user(UserId user_id, AccessRights access_r
}
bool ContactsManager::have_input_peer_user(const User *u, UserId user_id, AccessRights access_rights) const {
if (u == nullptr) {
LOG(DEBUG) << "Have no user";
if (user_messages_.count(user_id) != 0) {
return true;
if (u == nullptr || u->access_hash == -1 || u->is_min_access_hash) {
if (u == nullptr) {
LOG(DEBUG) << "Have no user";
} else {
LOG(DEBUG) << "Have user without access hash";
}
return false;
}
if (u->access_hash == -1 || u->is_min_access_hash) {
LOG(DEBUG) << "Have user without access hash";
if (user_messages_.count(user_id) != 0) {
return true;
}
@ -5395,11 +5392,11 @@ tl_object_ptr<telegram_api::InputPeer> ContactsManager::get_input_peer_user(User
return make_tl_object<telegram_api::inputPeerSelf>();
}
const User *u = get_user(user_id);
if ((u == nullptr || u->access_hash == -1 || u->is_min_access_hash) && td_->auth_manager_->is_bot() &&
user_id.is_valid()) {
return make_tl_object<telegram_api::inputPeerUser>(user_id.get(), 0);
}
if (!have_input_peer_user(u, user_id, access_rights)) {
if ((u == nullptr || u->access_hash == -1 || u->is_min_access_hash) && td_->auth_manager_->is_bot() &&
user_id.is_valid()) {
return make_tl_object<telegram_api::inputPeerUser>(user_id.get(), 0);
}
return nullptr;
}
if (u == nullptr || u->access_hash == -1 || u->is_min_access_hash) {
@ -5459,10 +5456,10 @@ bool ContactsManager::have_input_peer_channel(ChannelId channel_id, AccessRights
tl_object_ptr<telegram_api::InputPeer> ContactsManager::get_input_peer_channel(ChannelId channel_id,
AccessRights access_rights) const {
const Channel *c = get_channel(channel_id);
if (c == nullptr && td_->auth_manager_->is_bot() && channel_id.is_valid()) {
return make_tl_object<telegram_api::inputPeerChannel>(channel_id.get(), 0);
}
if (!have_input_peer_channel(c, channel_id, access_rights)) {
if (c == nullptr && td_->auth_manager_->is_bot() && channel_id.is_valid()) {
return make_tl_object<telegram_api::inputPeerChannel>(channel_id.get(), 0);
}
return nullptr;
}
if (c == nullptr) {