From 5b1d363918a7e69851decf1c849f31ef8ac89eae Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 25 Nov 2019 19:11:24 +0300 Subject: [PATCH] Add Chat.has_scheduled_messages flag. GitOrigin-RevId: 6d7f211647c738d5912476232e8842c245d1f884 --- td/generate/scheme/td_api.tl | 6 ++++- td/generate/scheme/td_api.tlo | Bin 164388 -> 164588 bytes td/telegram/ContactsManager.cpp | 6 +++++ td/telegram/ContactsManager.h | 3 +++ td/telegram/MessagesManager.cpp | 39 ++++++++++++++++++++++++++++---- td/telegram/MessagesManager.h | 5 ++++ 6 files changed, 54 insertions(+), 5 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 82c2f03ec..96253d6af 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -640,6 +640,7 @@ chatListArchive = ChatList; //@is_pinned True, if the chat is pinned //@is_marked_as_unread True, if the chat is marked as unread //@is_sponsored True, if the chat is sponsored by the user's MTProxy server +//@has_scheduled_messages True, if the chat has scheduled messages //@can_be_deleted_only_for_self True, if the chat messages can be deleted only for the current user while other users will continue to see the messages //@can_be_deleted_for_all_users True, if the chat messages can be deleted for all users //@can_be_reported True, if the chat can be reported to Telegram moderators through reportChat @@ -654,7 +655,7 @@ chatListArchive = ChatList; //@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat //@draft_message A draft of a message in the chat; may be null //@client_data Contains client-specific data associated with the chat. (For example, the chat position or local chat notification settings can be stored here.) Persistent if a message database is used -chat id:int53 type:ChatType chat_list:ChatList title:string photo:chatPhoto permissions:chatPermissions last_message:message order:int64 is_pinned:Bool is_marked_as_unread:Bool is_sponsored:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:chatNotificationSettings action_bar:ChatActionBar pinned_message_id:int53 reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat; +chat id:int53 type:ChatType chat_list:ChatList title:string photo:chatPhoto permissions:chatPermissions last_message:message order:int64 is_pinned:Bool is_marked_as_unread:Bool is_sponsored:Bool has_scheduled_messages:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:chatNotificationSettings action_bar:ChatActionBar pinned_message_id:int53 reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat; //@description Represents a list of chats @chat_ids List of chat identifiers chats chat_ids:vector = Chats; @@ -2741,6 +2742,9 @@ updateChatIsMarkedAsUnread chat_id:int53 is_marked_as_unread:Bool = Update; //@description A chat's is_sponsored field has changed @chat_id Chat identifier @is_sponsored New value of is_sponsored @order New value of chat order updateChatIsSponsored chat_id:int53 is_sponsored:Bool order:int64 = Update; +//@description A chat's has_scheduled_messages field has changed @chat_id Chat identifier @has_scheduled_messages New value of has_scheduled_messages +updateChatHasScheduledMessages chat_id:int53 has_scheduled_messages:Bool = Update; + //@description The value of the default disable_notification parameter, used when a message is sent to the chat, was changed @chat_id Chat identifier @default_disable_notification The new default_disable_notification value updateChatDefaultDisableNotification chat_id:int53 default_disable_notification:Bool = Update; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index c129798a2e6bf36a5ab114387650302ed17389e7..ed823aa273c38cd832cff5021f5b87d99e2ed829 100644 GIT binary patch delta 2274 zcmZ`)e`p(Z6wkXRv#S$=bX#2G7G0s$-mruI5jBIrii9>BCw5R#Y_c_2Scb9bFuExf zqg47cUYBo|rd#Z?u3Ovnw!|eul~#fj=^s@P6)FZSu5%SK*dLuZ@$TNeYf>uP>M&uYEk+Fa-Wo6=izO9`Jqo1)S8zgT8!u!?f`rK4Xy^ggwM!-Xc!KN zU&Zz#zF2~@hkKxEM+u=*qzYw6o{i{#bGlR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*tI|*!37$lI|f%-p#Aw4snF0O6`ERXcoxiT<3H$Nj~A(3v84tT zRP{9}bk=fIy^nZ9O{Slpx1Ra^Ug6W?yORx$|~p=*?*0=_%+C2oU_nqDs8;g%7zMHM=`F5h?WX;JoX|Ta(9uE ziA9PluPKjf-OlMH$F4V=LKC~crkv6Cb;=zt>B}S=bFgv=HZhsFM(tPZh`T|tu2XKd za{~m79lA+-%6v>yfI~@Pa}#yfUM5#DeY1}2Ta^k+NGi7>zr3Z^6nnE z0Lhk$(hN<`S13@uJn1U^a~mjFRi*Qm##>5i8pt!uk;uLc7W~)ezZi;lx*( zRj7VHLHe{C3zxT!ahbM#fffHy-ZE`TF2Ln^2Yqs%{+!9-FSsAfPp5Hz&D}lpKXjju A5C8xG diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index cdb820f7a..f9e42f148 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -8137,6 +8137,8 @@ void ContactsManager::on_get_user_full(tl_object_ptr &&u } td_->messages_manager_->on_update_dialog_folder_id(DialogId(user_id), folder_id); } + td_->messages_manager_->on_update_dialog_has_scheduled_messages( + DialogId(user_id), (user_full->flags_ & USER_FULL_FLAG_HAS_SCHEDULED_MESSAGES) != 0); UserFull *user = add_user_full(user_id); user->expires_at = Time::now() + USER_FULL_EXPIRE_TIME; @@ -8355,6 +8357,8 @@ void ContactsManager::on_get_chat_full(tl_object_ptr &&c } td_->messages_manager_->on_update_dialog_folder_id(DialogId(chat_id), folder_id); } + td_->messages_manager_->on_update_dialog_has_scheduled_messages( + DialogId(chat_id), (chat_full->flags_ & CHAT_FULL_FLAG_HAS_SCHEDULED_MESSAGES) != 0); ChatFull *chat = add_chat_full(chat_id); on_update_chat_full_invite_link(chat, std::move(chat_full->exported_invite_)); @@ -8495,6 +8499,8 @@ void ContactsManager::on_get_chat_full(tl_object_ptr &&c } td_->messages_manager_->on_update_dialog_folder_id(DialogId(channel_id), folder_id); } + td_->messages_manager_->on_update_dialog_has_scheduled_messages( + DialogId(channel_id), (channel_full->flags_ & CHANNEL_FULL_FLAG_HAS_SCHEDULED_MESSAGES) != 0); if (participant_count >= 190) { int32 online_member_count = 0; diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 139e0dfbf..4ac4ed376 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -882,6 +882,7 @@ class ContactsManager : public Actor { static constexpr int32 USER_FULL_FLAG_HAS_PINNED_MESSAGE = 1 << 6; static constexpr int32 USER_FULL_FLAG_CAN_PIN_MESSAGE = 1 << 7; static constexpr int32 USER_FULL_FLAG_HAS_FOLDER_ID = 1 << 11; + static constexpr int32 USER_FULL_FLAG_HAS_SCHEDULED_MESSAGES = 1 << 12; static constexpr int32 CHAT_FLAG_USER_IS_CREATOR = 1 << 0; static constexpr int32 CHAT_FLAG_USER_WAS_KICKED = 1 << 1; @@ -892,6 +893,7 @@ class ContactsManager : public Actor { static constexpr int32 CHAT_FLAG_WAS_MIGRATED = 1 << 6; static constexpr int32 CHAT_FULL_FLAG_HAS_PINNED_MESSAGE = 1 << 6; + static constexpr int32 CHAT_FULL_FLAG_HAS_SCHEDULED_MESSAGES = 1 << 8; static constexpr int32 CHAT_FULL_FLAG_HAS_FOLDER_ID = 1 << 11; static constexpr int32 CHANNEL_FLAG_USER_IS_CREATOR = 1 << 0; @@ -933,6 +935,7 @@ class ContactsManager : public Actor { static constexpr int32 CHANNEL_FULL_FLAG_CAN_SET_LOCATION = 1 << 16; static constexpr int32 CHANNEL_FULL_FLAG_HAS_SLOW_MODE_DELAY = 1 << 17; static constexpr int32 CHANNEL_FULL_FLAG_HAS_SLOW_MODE_NEXT_SEND_DATE = 1 << 18; + static constexpr int32 CHANNEL_FULL_FLAG_HAS_SCHEDULED_MESSAGES = 1 << 19; static constexpr int32 CHAT_INVITE_FLAG_IS_CHANNEL = 1 << 0; static constexpr int32 CHAT_INVITE_FLAG_IS_BROADCAST = 1 << 1; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index c97dd0abf..6988d1cc7 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -4170,6 +4170,7 @@ void MessagesManager::Dialog::store(StorerT &storer) const { STORE_FLAG(can_block_user); STORE_FLAG(can_share_phone_number); STORE_FLAG(can_report_location); + STORE_FLAG(has_scheduled_messages); END_STORE_FLAGS(); } @@ -4328,6 +4329,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) { PARSE_FLAG(can_block_user); PARSE_FLAG(can_share_phone_number); PARSE_FLAG(can_report_location); + PARSE_FLAG(has_scheduled_messages); END_PARSE_FLAGS(); } else { is_folder_id_inited = false; @@ -14540,10 +14542,10 @@ td_api::object_ptr MessagesManager::get_chat_object(const Dialog * get_chat_photo_object(td_->file_manager_.get(), get_dialog_photo(d->dialog_id)), get_dialog_permissions(d->dialog_id).get_chat_permissions_object(), get_message_object(d->dialog_id, get_message(d, d->last_message_id)), get_dialog_public_order(d), - d->pinned_order != DEFAULT_ORDER, d->is_marked_as_unread, d->order == SPONSORED_DIALOG_ORDER, can_delete_for_self, - can_delete_for_all_users, can_report_dialog(d->dialog_id), d->notification_settings.silent_send_message, - d->server_unread_count + d->local_unread_count, d->last_read_inbox_message_id.get(), - d->last_read_outbox_message_id.get(), d->unread_mention_count, + d->pinned_order != DEFAULT_ORDER, d->is_marked_as_unread, d->order == SPONSORED_DIALOG_ORDER, + d->has_scheduled_messages, can_delete_for_self, can_delete_for_all_users, can_report_dialog(d->dialog_id), + d->notification_settings.silent_send_message, d->server_unread_count + d->local_unread_count, + d->last_read_inbox_message_id.get(), d->last_read_outbox_message_id.get(), d->unread_mention_count, get_chat_notification_settings_object(&d->notification_settings), get_chat_action_bar_object(d), d->pinned_message_id.get(), d->reply_markup_message_id.get(), get_draft_message_object(d->draft_message), d->client_data); @@ -22155,6 +22157,35 @@ void MessagesManager::set_dialog_pinned_message_id(Dialog *d, MessageId pinned_m make_tl_object(d->dialog_id.get(), pinned_message_id.get())); } +void MessagesManager::on_update_dialog_has_scheduled_messages(DialogId dialog_id, bool has_scheduled_messages) { + if (!dialog_id.is_valid()) { + LOG(ERROR) << "Receive has_scheduled_messages in invalid " << dialog_id; + return; + } + + auto d = get_dialog_force(dialog_id); + if (d == nullptr) { + // nothing to do + return; + } + + if (d->has_scheduled_messages != has_scheduled_messages) { + set_dialog_has_scheduled_messages(d, has_scheduled_messages); + } +} + +void MessagesManager::set_dialog_has_scheduled_messages(Dialog *d, bool has_scheduled_messages) { + CHECK(d != nullptr); + CHECK(d->has_scheduled_messages != has_scheduled_messages); + d->has_scheduled_messages = has_scheduled_messages; + on_dialog_updated(d->dialog_id, "set_dialog_has_scheduled_messages"); + + LOG(INFO) << "Set " << d->dialog_id << " has_scheduled_messages to " << has_scheduled_messages; + LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_has_scheduled_messages"; + send_closure(G()->td(), &Td::send_update, + td_api::make_object(d->dialog_id.get(), has_scheduled_messages)); +} + void MessagesManager::on_update_dialog_folder_id(DialogId dialog_id, FolderId folder_id) { auto d = get_dialog_force(dialog_id); if (d == nullptr) { diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 7ad8e1d31..d81bb3188 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -285,6 +285,8 @@ class MessagesManager : public Actor { void on_update_dialog_pinned_message_id(DialogId dialog_id, MessageId pinned_message_id); + void on_update_dialog_has_scheduled_messages(DialogId dialog_id, bool has_scheduled_messages); + void on_update_dialog_folder_id(DialogId dialog_id, FolderId folder_id); void on_update_service_notification(tl_object_ptr &&update, @@ -1080,6 +1082,7 @@ class MessagesManager : public Actor { bool is_folder_id_inited = false; bool need_repair_server_unread_count = false; bool is_marked_as_unread = false; + bool has_scheduled_messages = false; bool increment_view_counter = false; @@ -1875,6 +1878,8 @@ class MessagesManager : public Actor { void set_dialog_pinned_message_id(Dialog *d, MessageId pinned_message_id); + void set_dialog_has_scheduled_messages(Dialog *d, bool has_scheduled_messages); + void set_dialog_folder_id(Dialog *d, FolderId folder_id); void toggle_dialog_is_pinned_on_server(DialogId dialog_id, bool is_pinned, uint64 logevent_id);