diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index af17ed2c4..4e57dd8fc 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -128,7 +128,7 @@ chatPhotoEmpty#37c1011c = ChatPhoto; chatPhoto#d20b9f3c flags:# has_video:flags.0?true photo_small:FileLocation photo_big:FileLocation dc_id:int = ChatPhoto; messageEmpty#83e5de54 id:int = Message; -message#f52e6b7f flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true id:int from_id:flags.8?int to_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?int reply_to_msg_id:flags.3?int date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long restriction_reason:flags.22?Vector = Message; +message#8a7e027d flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true id:int from_id:flags.8?int to_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?int reply_to_msg_id:flags.3?int reply_to_top_id:flags.24?int date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long restriction_reason:flags.22?Vector = Message; messageService#9e19a1f6 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?int to_id:Peer reply_to_msg_id:flags.3?int date:int action:MessageAction = Message; messageMediaEmpty#3ded6320 = MessageMedia; @@ -347,6 +347,7 @@ updateDialogFilters#3504914f = Update; updatePhoneCallSignalingData#2661bf09 phone_call_id:long data:bytes = Update; updateChannelParticipant#65d2b464 flags:# channel_id:int date:int user_id:int prev_participant:flags.0?ChannelParticipant new_participant:flags.1?ChannelParticipant qts:int = Update; updateChannelMessageForwards#6e8a84df channel_id:int id:int forwards:int = Update; +updateReadDiscussion#119fb587 peer:Peer msg_id:int read_max_id:int = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -1139,10 +1140,6 @@ stats.megagroupStats#ef7ff916 period:StatsDateRangeDays members:StatsAbsValueAnd globalPrivacySettings#bea2f424 flags:# archive_and_mute_new_noncontact_peers:flags.0?Bool = GlobalPrivacySettings; -messageViews#6d24f493 views:int forwards:int = MessageViews; - -stats.messageStats#8999f295 views_graph:StatsGraph = stats.MessageStats; - help.countryCode#4203c5ef flags:# country_code:string prefixes:flags.0?Vector patterns:flags.1?Vector = help.CountryCode; help.country#c3878e23 flags:# hidden:flags.0?true iso2:string default_name:string name:flags.1?string country_codes:Vector = help.Country; @@ -1150,6 +1147,16 @@ help.country#c3878e23 flags:# hidden:flags.0?true iso2:string default_name:strin help.countriesListNotModified#93cc1f32 = help.CountriesList; help.countriesList#87d0759e countries:Vector hash:int = help.CountriesList; +messageReplies#82e3c815 flags:# comments:flags.0?true replies:int replies_pts:int recent_repliers:flags.1?Vector channel_id:flags.0?int = MessageReplies; + +messageViews#455b853d flags:# views:flags.0?int forwards:flags.1?int replies:flags.2?MessageReplies = MessageViews; + +messages.messageViews#2c3f2ae2 views:Vector users:Vector = messages.MessageViews; + +stats.messageStats#8999f295 views_graph:StatsGraph = stats.MessageStats; + +messages.discussionMessage#d25fad90 message:Message read_max_id:int chats:Vector users:Vector = messages.DiscussionMessage; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1274,7 +1281,7 @@ contacts.getLocated#d348bc44 flags:# background:flags.1?true geo_point:InputGeoP messages.getMessages#63c66506 id:Vector = messages.Messages; messages.getDialogs#a0ee3b73 flags:# exclude_pinned:flags.0?true folder_id:flags.1?int offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:int = messages.Dialogs; messages.getHistory#dcbb8260 peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; -messages.search#8614ef68 flags:# peer:InputPeer q:string from_id:flags.0?InputUser filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; +messages.search#4e17810b flags:# peer:InputPeer q:string from_id:flags.0?InputUser top_msg_id:flags.1?int filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; messages.readHistory#e306d3a peer:InputPeer max_id:int = messages.AffectedMessages; messages.deleteHistory#1c015b09 flags:# just_clear:flags.0?true revoke:flags.1?true peer:InputPeer max_id:int = messages.AffectedHistory; messages.deleteMessages#e58e95d2 flags:# revoke:flags.0?true id:Vector = messages.AffectedMessages; @@ -1315,10 +1322,10 @@ messages.getStickerSet#2619a90e stickerset:InputStickerSet = messages.StickerSet messages.installStickerSet#c78fe460 stickerset:InputStickerSet archived:Bool = messages.StickerSetInstallResult; messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool; messages.startBot#e6df7378 bot:InputUser peer:InputPeer random_id:long start_param:string = Updates; -messages.getMessagesViews#fdac5dba peer:InputPeer id:Vector increment:Bool = Vector; +messages.getMessagesViews#5784d3e1 peer:InputPeer id:Vector increment:Bool = messages.MessageViews; messages.editChatAdmin#a9e69f2e chat_id:int user_id:InputUser is_admin:Bool = Bool; messages.migrateChat#15a3b8e3 chat_id:int = Updates; -messages.searchGlobal#734dd16d flags:# folder_id:flags.0?int q:string filter:MessagesFilter offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; +messages.searchGlobal#4bc6589a flags:# folder_id:flags.0?int q:string filter:MessagesFilter min_date:int max_date:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; messages.reorderStickerSets#78337739 flags:# masks:flags.0?true order:Vector = Bool; messages.getDocumentByHash#338e2464 sha256:bytes size:int mime_type:string = Document; messages.getSavedGifs#83bf3d52 hash:int = messages.SavedGifs; @@ -1394,6 +1401,9 @@ messages.getSuggestedDialogFilters#a29cd42c = Vector; messages.updateDialogFilter#1ad4a04a flags:# id:int filter:flags.0?DialogFilter = Bool; messages.updateDialogFiltersOrder#c563c1e4 order:Vector = Bool; messages.getOldFeaturedStickers#5fe7025b offset:int limit:int hash:int = messages.FeaturedStickers; +messages.getReplies#fda52fdc peer:InputPeer msg_id:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; +messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage; +messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool; updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index d8d4c7c1b..5fd375dff 100644 Binary files a/td/generate/scheme/telegram_api.tlo and b/td/generate/scheme/telegram_api.tlo differ diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index c6959095f..8b778753d 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -1280,13 +1280,19 @@ class GetMessagesViewsQuery : public Td::ResultHandler { return on_error(id, result_ptr.move_as_error()); } - auto interaction_infos = result_ptr.move_as_ok(); + auto result = result_ptr.move_as_ok(); + td->contacts_manager_->on_get_users(std::move(result->users_), "GetMessagesViewsQuery"); + auto interaction_infos = std::move(result->views_); if (message_ids_.size() != interaction_infos.size()) { return on_error(id, Status::Error(500, "Wrong number of message views returned")); } for (size_t i = 0; i < message_ids_.size(); i++) { - td->messages_manager_->on_update_message_interaction_info( - {dialog_id_, message_ids_[i]}, interaction_infos[i]->views_, interaction_infos[i]->forwards_); + const auto *info = interaction_infos[i].get(); + auto flags = info->flags_; + auto view_count = (flags & telegram_api::messageViews::VIEWS_MASK) != 0 ? info->views_ : 0; + auto forward_count = (flags & telegram_api::messageViews::FORWARDS_MASK) != 0 ? info->forwards_ : 0; + td->messages_manager_->on_update_message_interaction_info({dialog_id_, message_ids_[i]}, view_count, + forward_count); } } @@ -1611,7 +1617,7 @@ class SearchMessagesQuery : public Td::ResultHandler { } send_query(G()->net_query_creator().create(telegram_api::messages_search( - flags, std::move(input_peer), query, std::move(sender_input_user), get_input_messages_filter(filter), 0, + flags, std::move(input_peer), query, std::move(sender_input_user), 0, get_input_messages_filter(filter), 0, std::numeric_limits::max(), from_message_id.get_server_message_id().get(), offset, limit, std::numeric_limits::max(), 0, 0))); } @@ -1674,7 +1680,7 @@ class SearchMessagesGlobalQuery : public Td::ResultHandler { flags |= telegram_api::messages_searchGlobal::FOLDER_ID_MASK; } send_query(G()->net_query_creator().create(telegram_api::messages_searchGlobal( - flags, folder_id.get(), query, get_input_messages_filter(filter), offset_date_, std::move(input_peer), + flags, folder_id.get(), query, get_input_messages_filter(filter), 0, 0, offset_date_, std::move(input_peer), offset_message_id.get_server_message_id().get(), limit))); } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index b42b17ae5..553333eed 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -163,6 +163,8 @@ class MessagesManager : public Actor { static constexpr int32 MESSAGE_FLAG_IS_LEGACY = 1 << 19; static constexpr int32 MESSAGE_FLAG_HIDE_EDIT_DATE = 1 << 21; static constexpr int32 MESSAGE_FLAG_IS_RESTRICTED = 1 << 22; + static constexpr int32 MESSAGE_FLAG_HAS_REPLY_INFO = 1 << 23; + static constexpr int32 MESSAGE_FLAG_HAS_RECENT_REPLIERS = 1 << 24; static constexpr int32 SEND_MESSAGE_FLAG_IS_REPLY = 1 << 0; static constexpr int32 SEND_MESSAGE_FLAG_DISABLE_WEB_PAGE_PREVIEW = 1 << 1; diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 954a229c8..a3f7f5c00 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -506,6 +506,14 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_ CHECK(message->media_ == nullptr); } + if (message->replies_ != nullptr) { + for (auto &user_id : message->replies_->recent_repliers_) { + if (!is_acceptable_user(UserId(user_id))) { + return false; + } + } + } + break; } case telegram_api::messageService::ID: { @@ -695,8 +703,8 @@ void UpdatesManager::on_get_updates(tl_object_ptr &&updat update->flags_, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, update->id_, from_id, make_tl_object(update->user_id_), std::move(update->fwd_from_), - update->via_bot_id_, update->reply_to_msg_id_, update->date_, update->message_, nullptr, nullptr, - std::move(update->entities_), 0, 0, 0, "", 0, Auto()), + update->via_bot_id_, update->reply_to_msg_id_, 0, update->date_, update->message_, nullptr, nullptr, + std::move(update->entities_), 0, 0, nullptr, 0, string(), 0, Auto()), update->pts_, update->pts_count_), 0, "telegram_api::updatesShortMessage"); break; @@ -713,16 +721,16 @@ void UpdatesManager::on_get_updates(tl_object_ptr &&updat } update->flags_ |= MessagesManager::MESSAGE_FLAG_HAS_FROM_ID; - on_pending_update( - make_tl_object( - make_tl_object( - update->flags_, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, - false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, update->id_, - update->from_id_, make_tl_object(update->chat_id_), - std::move(update->fwd_from_), update->via_bot_id_, update->reply_to_msg_id_, update->date_, - update->message_, nullptr, nullptr, std::move(update->entities_), 0, 0, 0, "", 0, Auto()), - update->pts_, update->pts_count_), - 0, "telegram_api::updatesShortChatMessage"); + on_pending_update(make_tl_object( + make_tl_object( + update->flags_, false /*ignored*/, false /*ignored*/, false /*ignored*/, + false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, + false /*ignored*/, update->id_, update->from_id_, + make_tl_object(update->chat_id_), std::move(update->fwd_from_), + update->via_bot_id_, update->reply_to_msg_id_, 0, update->date_, update->message_, + nullptr, nullptr, std::move(update->entities_), 0, 0, nullptr, 0, string(), 0, Auto()), + update->pts_, update->pts_count_), + 0, "telegram_api::updatesShortChatMessage"); break; } case telegram_api::updateShort::ID: { @@ -2186,4 +2194,7 @@ void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { } +void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { +} + } // namespace td diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index a0c931705..45c4978e3 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -315,6 +315,8 @@ class UpdatesManager : public Actor { // unsupported updates void on_update(tl_object_ptr update, bool /*force_apply*/); + + void on_update(tl_object_ptr update, bool /*force_apply*/); }; } // namespace td diff --git a/td/telegram/Version.h b/td/telegram/Version.h index fd62e28a7..25fa03756 100644 --- a/td/telegram/Version.h +++ b/td/telegram/Version.h @@ -8,7 +8,7 @@ namespace td { -constexpr int32 MTPROTO_LAYER = 118; +constexpr int32 MTPROTO_LAYER = 119; enum class Version : int32 { Initial, // 0