diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index 8de34135..48271683 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -160,6 +160,7 @@ messageActionCustomAction#fae69f56 message:string = MessageAction; messageActionBotAllowed#abe9affe domain:string = MessageAction; messageActionSecureValuesSentMe#1b287353 values:Vector credentials:SecureCredentialsEncrypted = MessageAction; messageActionSecureValuesSent#d95c6154 types:Vector = MessageAction; +messageActionContactSignUp#70ef8294 flags:# silent:flags.0?true = MessageAction; dialog#e4def5db flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage = Dialog; @@ -264,7 +265,6 @@ updateChatParticipants#7761198 participants:ChatParticipants = Update; updateUserStatus#1bfbd823 user_id:int status:UserStatus = Update; updateUserName#a7332b73 user_id:int first_name:string last_name:string username:string = Update; updateUserPhoto#95313b0c user_id:int date:int photo:UserProfilePhoto previous:Bool = Update; -updateContactRegistered#2575bbb9 user_id:int date:int = Update; updateContactLink#9d2e67c5 user_id:int my_link:ContactLink foreign_link:ContactLink = Update; updateNewEncryptedMessage#12bcbd9a message:EncryptedMessage qts:int = Update; updateEncryptedChatTyping#1710f156 chat_id:int = Update; @@ -1037,6 +1037,9 @@ account.finishTakeoutSession#1d2652ee flags:# success:flags.0?true = Bool; account.confirmPasswordEmail#8fdf1920 code:string = Bool; account.resendPasswordEmail#7a7f2a15 = Bool; account.cancelPasswordEmail#c1cbd5b6 = Bool; +account.getContactSignUpNotification#9f07c728 = Bool; +account.setContactSignUpNotification#cff43f61 silent:Bool = Bool; +account.getNotifyExceptions#53577479 flags:# compare_sound:flags.1?true peer:flags.0?InputNotifyPeer = Updates; users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#ca30a5b1 id:InputUser = UserFull; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index 94148039..33dc5539 100644 Binary files a/td/generate/scheme/telegram_api.tlo and b/td/generate/scheme/telegram_api.tlo differ diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 3921f882..7f048d51 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -8870,7 +8870,7 @@ ContactsManager::ChannelFull *ContactsManager::get_channel_full(ChannelId channe } auto channel_full = &p->second; - if (channel_full->is_expired()) { + if (channel_full->is_expired() && !td_->auth_manager_->is_bot()) { auto input_channel = get_input_channel(channel_id); CHECK(input_channel != nullptr); send_get_channel_full_query(channel_id, std::move(input_channel), Auto()); diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 7701c7a7..e0afd1ca 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -422,7 +422,7 @@ class MessageChatSetTtl : public MessageContent { class MessageUnsupported : public MessageContent { public: - static constexpr int32 CURRENT_VERSION = 1; + static constexpr int32 CURRENT_VERSION = 2; int32 version = CURRENT_VERSION; MessageUnsupported() = default; @@ -4119,6 +4119,10 @@ unique_ptr get_action_message_content(Td *td, tl_object_ptrfile_manager_.get(), std::move(secure_values->values_)), get_encrypted_secure_credentials(std::move(secure_values->credentials_))); } + case telegram_api::messageActionContactSignUp::ID: { + LOG_IF(ERROR, td->auth_manager_->is_bot()) << "Receive ContactRegistered in " << owner_dialog_id; + return td::make_unique(); + } default: UNREACHABLE(); } diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index d48276db..ada0a611 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -4758,61 +4758,6 @@ void MessagesManager::on_update_service_notification(tl_object_ptr &&update) { - if (update->date_ <= 0) { - LOG(ERROR) << "Receive wrong date " << update->date_ << " in updateContactRegistered"; - return; - } - UserId user_id(update->user_id_); - if (!user_id.is_valid()) { - LOG(ERROR) << "Receive invalid " << user_id << " in updateContactRegistered"; - return; - } - - if (!td_->auth_manager_->is_bot() && - !G()->shared_config().get_option_boolean("disable_contact_registered_notifications")) { - DialogId dialog_id(user_id); - force_create_dialog(dialog_id, "on_update_contact_registered"); - Dialog *d = get_dialog(dialog_id); - CHECK(d != nullptr); - - if (d->has_contact_registered_message) { - LOG(INFO) << "Ignore duplicate updateContactRegistered about " << user_id; - return; - } - if (d->last_message_id.is_valid()) { - auto m = get_message(d, d->last_message_id); - CHECK(m != nullptr); - if (m->content->get_type() == MessageContentType::ContactRegistered) { - LOG(INFO) << "Ignore duplicate updateContactRegistered about " << user_id; - return; - } - } - - auto new_message = make_unique(); - new_message->message_id = get_next_local_message_id(d); - new_message->random_y = get_random_y(new_message->message_id); - new_message->sender_user_id = user_id; - new_message->date = update->date_; - new_message->content = create_contact_registered_message_content(); - new_message->have_previous = true; - new_message->have_next = true; - - bool need_update = true; - bool need_update_dialog_pos = false; - - const Message *m = add_message_to_dialog(d, std::move(new_message), true, &need_update, &need_update_dialog_pos, - "on_update_contact_registered"); - if (m != nullptr && need_update) { - send_update_new_message(d, m); - } - - if (need_update_dialog_pos) { - send_update_chat_last_message(d, "on_update_contact_registered"); - } - } -} - void MessagesManager::on_update_new_channel_message(tl_object_ptr &&update) { int new_pts = update->pts_; int pts_count = update->pts_count_; @@ -8050,6 +7995,10 @@ int32 MessagesManager::calc_new_unread_count(Dialog *d, MessageId max_message_id } void MessagesManager::repair_server_unread_count(DialogId dialog_id, int32 unread_count) { + if (td_->auth_manager_->is_bot()) { + return; + } + LOG(INFO) << "Repair server unread count in " << dialog_id << " from " << unread_count; create_actor("RepairServerUnreadCountSleepActor", 0.2, PromiseCreator::lambda([actor_id = actor_id(this), dialog_id](Result result) { @@ -8063,6 +8012,9 @@ void MessagesManager::repair_channel_server_unread_count(Dialog *d) { CHECK(d != nullptr); CHECK(d->dialog_id.get_type() == DialogType::Channel); + if (td_->auth_manager_->is_bot()) { + return; + } if (d->last_read_inbox_message_id.get() >= d->last_new_message_id.get()) { // all messages are already read return; diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index c3421ca3..71d32e1e 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -280,8 +280,6 @@ class MessagesManager : public Actor { void on_update_service_notification(tl_object_ptr &&update); - void on_update_contact_registered(tl_object_ptr &&update); - void on_update_new_channel_message(tl_object_ptr &&update); void on_update_edit_channel_message(tl_object_ptr &&update); diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 08e3de53..b6ee0b61 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -499,6 +499,7 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_ case telegram_api::messageActionScreenshotTaken::ID: case telegram_api::messageActionSecureValuesSent::ID: case telegram_api::messageActionSecureValuesSentMe::ID: + case telegram_api::messageActionContactSignUp::ID: break; case telegram_api::messageActionChatCreate::ID: { auto chat_create = static_cast(action); @@ -1437,11 +1438,6 @@ void UpdatesManager::on_update(tl_object_ptrmessages_manager_->on_update_service_notification(std::move(update)); } -void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { - CHECK(update != nullptr); - td_->messages_manager_->on_update_contact_registered(std::move(update)); -} - void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { CHECK(update != nullptr); td_->messages_manager_->on_update_read_channel_inbox(std::move(update)); diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index ef2b7c8b..a6d2e492 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -212,7 +212,6 @@ class UpdatesManager : public Actor { void on_update(tl_object_ptr update, bool /*force_apply*/); void on_update(tl_object_ptr update, bool force_apply); - void on_update(tl_object_ptr update, bool /*force_apply*/); void on_update(tl_object_ptr update, bool /*force_apply*/); diff --git a/td/telegram/net/MtprotoHeader.cpp b/td/telegram/net/MtprotoHeader.cpp index 1602e32e..481cab87 100644 --- a/td/telegram/net/MtprotoHeader.cpp +++ b/td/telegram/net/MtprotoHeader.cpp @@ -21,7 +21,7 @@ class HeaderStorer { } template void store(StorerT &storer) const { - constexpr int32 LAYER = 89; + constexpr int32 LAYER = 90; using td::store; // invokeWithLayer#da9b0d0d {X:Type} layer:int query:!X = X;