Allow sending messages to user after receiving a message from them.

This commit is contained in:
levlam 2024-01-25 20:56:10 +03:00
parent 8c2375fdfe
commit 2acbcdbb60
3 changed files with 13 additions and 0 deletions

View File

@ -5593,6 +5593,13 @@ void ContactsManager::on_get_is_premium_required_to_contact_users(vector<UserId>
promise.set_value(Unit());
}
void ContactsManager::allow_send_message_to_user(UserId user_id) {
if (get_user_full(user_id) == nullptr) {
CHECK(user_id.is_valid());
user_full_contact_require_premium_[user_id] = true;
}
}
void ContactsManager::load_contacts(Promise<Unit> &&promise) {
if (td_->auth_manager_->is_bot()) {
are_contacts_loaded_ = true;

View File

@ -188,6 +188,8 @@ class ContactsManager final : public Actor {
void can_send_message_to_user(UserId user_id, bool force,
Promise<td_api::object_ptr<td_api::CanSendMessageToUserResult>> &&promise);
void allow_send_message_to_user(UserId user_id);
void on_imported_contacts(int64 random_id, Result<tl_object_ptr<telegram_api::contacts_importedContacts>> result);
void on_deleted_contacts(const vector<UserId> &deleted_contact_user_ids);

View File

@ -33198,6 +33198,10 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
CHECK(is_inserted);
}
if (!td_->auth_manager_->is_bot() && dialog_type == DialogType::User && !m->is_outgoing) {
td_->contacts_manager_->allow_send_message_to_user(dialog_id.get_user_id());
}
switch (dialog_type) {
case DialogType::User:
case DialogType::Chat: