From 905a024aed3a0a94b1939dddf7cdfe2f0a211b9c Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 15 Apr 2019 13:20:07 +0400 Subject: [PATCH] Update API scheme to layer 99. --- Telegram/Resources/scheme.tl | 45 +++++---- Telegram/SourceFiles/apiwrap.cpp | 22 +++-- .../SourceFiles/dialogs/dialogs_widget.cpp | 9 +- .../SourceFiles/export/export_api_wrap.cpp | 2 + Telegram/SourceFiles/mainwidget.cpp | 96 ++++++++----------- Telegram/SourceFiles/mtproto/connection.cpp | 2 +- 6 files changed, 92 insertions(+), 84 deletions(-) diff --git a/Telegram/Resources/scheme.tl b/Telegram/Resources/scheme.tl index 647a5b954..a0aca70b5 100644 --- a/Telegram/Resources/scheme.tl +++ b/Telegram/Resources/scheme.tl @@ -214,7 +214,7 @@ storage.fileMp4#b3cea0e4 = storage.FileType; storage.fileWebp#1081464c = storage.FileType; userEmpty#200250ba id:int = User; -user#2e13f4c3 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?string bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; +user#2e13f4c3 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?string bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; userProfilePhoto#ecd75d8c photo_id:long photo_small:FileLocation photo_big:FileLocation dc_id:int = UserProfilePhoto; @@ -229,11 +229,11 @@ userStatusLastMonth#77ebc742 = UserStatus; chatEmpty#9ba2d800 id:int = Chat; chat#3bda1bde flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true deactivated:flags.5?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; chatForbidden#7328bdb id:int title:string = Chat; -channel#4df30834 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?string admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat; +channel#4df30834 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?string admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat; channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat; -chatFull#22a235da flags:# can_set_username:flags.7?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int = ChatFull; -channelFull#1c87a71a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_view_stats:flags.12?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int = ChatFull; +chatFull#1b7c9db3 flags:# can_set_username:flags.7?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int = ChatFull; +channelFull#3648977 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_view_stats:flags.12?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int pts:int = ChatFull; chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant; chatParticipantCreator#da13538a user_id:int = ChatParticipant; @@ -286,7 +286,8 @@ messageActionSecureValuesSentMe#1b287353 values:Vector credentials: messageActionSecureValuesSent#d95c6154 types:Vector = MessageAction; messageActionContactSignUp#f3f25f76 = 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; +dialog#2c171f72 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 folder_id:flags.4?int = Dialog; +dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; photoEmpty#2331b22d id:long = Photo; photo#d07504a5 flags:# has_stickers:flags.0?true id:long access_hash:long file_reference:bytes date:int sizes:Vector dc_id:int = Photo; @@ -327,7 +328,7 @@ inputReportReasonChildAbuse#adf44ee3 = ReportReason; inputReportReasonOther#e1746d0a text:string = ReportReason; inputReportReasonCopyright#9b89f93a = ReportReason; -userFull#8ea4a881 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true user:User about:flags.1?string link:contacts.Link profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int = UserFull; +userFull#745559cc flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true user:User about:flags.1?string link:contacts.Link profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int = UserFull; contact#f911c994 user_id:int mutual:Bool = Contact; @@ -402,14 +403,14 @@ updateNotifySettings#bec268ef peer:NotifyPeer notify_settings:PeerNotifySettings updateServiceNotification#ebe46819 flags:# popup:flags.0?true inbox_date:flags.1?int type:string message:string media:MessageMedia entities:Vector = Update; updatePrivacy#ee3b272a key:PrivacyKey rules:Vector = Update; updateUserPhone#12b9417b user_id:int phone:string = Update; -updateReadHistoryInbox#9961fd5c peer:Peer max_id:int pts:int pts_count:int = Update; +updateReadHistoryInbox#9c974fdf flags:# folder_id:flags.0?int peer:Peer max_id:int still_unread_count:int pts:int pts_count:int = Update; updateReadHistoryOutbox#2f2f21bf peer:Peer max_id:int pts:int pts_count:int = Update; updateWebPage#7f891213 webpage:WebPage pts:int pts_count:int = Update; updateReadMessagesContents#68c13933 messages:Vector pts:int pts_count:int = Update; updateChannelTooLong#eb0467fb flags:# channel_id:int pts:flags.0?int = Update; updateChannel#b6d45656 channel_id:int = Update; updateNewChannelMessage#62ba04d9 message:Message pts:int pts_count:int = Update; -updateReadChannelInbox#4214f37f channel_id:int max_id:int = Update; +updateReadChannelInbox#330b5424 flags:# folder_id:flags.0?int channel_id:int max_id:int still_unread_count:int pts:int = Update; updateDeleteChannelMessages#c37521c9 channel_id:int messages:Vector pts:int pts_count:int = Update; updateChannelMessageViews#98a12b4b channel_id:int id:int views:int = Update; updateChatParticipantAdmin#b6901959 chat_id:int user_id:int is_admin:Bool version:int = Update; @@ -431,8 +432,8 @@ updateRecentStickers#9a422c20 = Update; updateConfig#a229dd06 = Update; updatePtsChanged#3354678f = Update; updateChannelWebPage#40771900 channel_id:int webpage:WebPage pts:int pts_count:int = Update; -updateDialogPinned#19d27f3c flags:# pinned:flags.0?true peer:DialogPeer = Update; -updatePinnedDialogs#ea4cb65b flags:# order:flags.0?Vector = Update; +updateDialogPinned#6e6fe51c flags:# pinned:flags.0?true folder_id:flags.1?int peer:DialogPeer = Update; +updatePinnedDialogs#fa0f3ca2 flags:# folder_id:flags.1?int order:flags.0?Vector = Update; updateBotWebhookJSON#8317c0c3 data:DataJSON = Update; updateBotWebhookJSONQuery#9b9240a6 query_id:long data:DataJSON timeout:int = Update; updateBotShippingQuery#e0cdc940 query_id:long user_id:int payload:bytes shipping_address:PostAddress = Update; @@ -449,6 +450,7 @@ updateUserPinnedMessage#4c43da18 user_id:int id:int = Update; updateChatPinnedMessage#e10db349 chat_id:int id:int version:int = Update; updateMessagePoll#aca1657b flags:# poll_id:long poll:flags.0?Poll results:PollResults = Update; updateChatDefaultBannedRights#54c01850 peer:Peer default_banned_rights:ChatBannedRights version:int = Update; +updateFolderPeers#19360dc0 folder_peers:Vector pts:int pts_count:int = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -475,7 +477,7 @@ upload.fileCdnRedirect#f18cda44 dc_id:int file_token:bytes encryption_key:bytes dcOption#18b7a10d flags:# ipv6:flags.0?true media_only:flags.1?true tcpo_only:flags.2?true cdn:flags.3?true static:flags.4?true id:int ip_address:string port:int secret:flags.10?bytes = DcOption; -config#e6ca25f6 flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true preload_featured_stickers:flags.4?true ignore_phone_entities:flags.5?true revoke_pm_inbox:flags.6?true blocked_mode:flags.8?true pfs_enabled:flags.13?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector dc_txt_domain_name:string chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int revoke_time_limit:int revoke_pm_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string autoupdate_url_prefix:flags.7?string gif_search_username:flags.9?string venue_search_username:flags.10?string img_search_username:flags.11?string static_maps_provider:flags.12?string caption_length_max:int message_length_max:int webfile_dc_id:int suggested_lang_code:flags.2?string lang_pack_version:flags.2?int base_lang_pack_version:flags.2?int = Config; +config#330b4067 flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true preload_featured_stickers:flags.4?true ignore_phone_entities:flags.5?true revoke_pm_inbox:flags.6?true blocked_mode:flags.8?true pfs_enabled:flags.13?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector dc_txt_domain_name:string chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int revoke_time_limit:int revoke_pm_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int pinned_infolder_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string autoupdate_url_prefix:flags.7?string gif_search_username:flags.9?string venue_search_username:flags.10?string img_search_username:flags.11?string static_maps_provider:flags.12?string caption_length_max:int message_length_max:int webfile_dc_id:int suggested_lang_code:flags.2?string lang_pack_version:flags.2?int base_lang_pack_version:flags.2?int = Config; nearestDc#8e1a1775 country:string this_dc:int nearest_dc:int = NearestDc; @@ -670,7 +672,7 @@ contacts.resolvedPeer#7f077ad9 peer:Peer chats:Vector users:Vector = messageRange#ae30253 min_id:int max_id:int = MessageRange; updates.channelDifferenceEmpty#3e11affb flags:# final:flags.0?true pts:int timeout:flags.1?int = updates.ChannelDifference; -updates.channelDifferenceTooLong#6a9d7b35 flags:# final:flags.0?true pts:int timeout:flags.1?int top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int messages:Vector chats:Vector users:Vector = updates.ChannelDifference; +updates.channelDifferenceTooLong#a4bcc6fe flags:# final:flags.0?true timeout:flags.1?int dialog:Dialog messages:Vector chats:Vector users:Vector = updates.ChannelDifference; updates.channelDifference#2064674e flags:# final:flags.0?true pts:int timeout:flags.1?int new_messages:Vector other_updates:Vector chats:Vector users:Vector = updates.ChannelDifference; channelMessagesFilterEmpty#94d42ee7 = ChannelMessagesFilter; @@ -974,8 +976,10 @@ inputMessageReplyTo#bad88395 id:int = InputMessage; inputMessagePinned#86872538 = InputMessage; inputDialogPeer#fcaafeb7 peer:InputPeer = InputDialogPeer; +inputDialogPeerFolder#64600527 folder_id:int = InputDialogPeer; dialogPeer#e56dbf05 peer:Peer = DialogPeer; +dialogPeerFolder#514519e2 folder_id:int = DialogPeer; messages.foundStickerSetsNotModified#d54b65d = messages.FoundStickerSets; messages.foundStickerSets#5108d648 hash:int sets:Vector = messages.FoundStickerSets; @@ -1135,6 +1139,12 @@ emojiLanguage#b3fb5361 lang_code:string = EmojiLanguage; fileLocationToBeDeprecated#bc7fc6cd volume_id:long local_id:int = FileLocation; +folder#ff544e65 flags:# autofill_new_broadcasts:flags.0?true autofill_public_groups:flags.1?true autofill_new_correspondents:flags.2?true id:int title:string photo:flags.3?ChatPhoto = Folder; + +inputFolderPeer#fbd2c296 peer:InputPeer folder_id:int = InputFolderPeer; + +folderPeer#e9baa668 peer:Peer folder_id:int = FolderPeer; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1240,7 +1250,7 @@ contacts.getSaved#82f1e39f = Vector; contacts.toggleTopPeers#8514bdda enabled:Bool = Bool; messages.getMessages#63c66506 id:Vector = messages.Messages; -messages.getDialogs#b098aee6 flags:# exclude_pinned:flags.0?true offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:int = messages.Dialogs; +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.readHistory#e306d3a peer:InputPeer max_id:int = messages.AffectedMessages; @@ -1320,8 +1330,8 @@ messages.getCommonChats#d0a48c4 user_id:InputUser max_id:int limit:int = message messages.getAllChats#eba80ff0 except_ids:Vector = messages.Chats; messages.getWebPage#32ca8f91 url:string hash:int = WebPage; messages.toggleDialogPin#a731e257 flags:# pinned:flags.0?true peer:InputDialogPeer = Bool; -messages.reorderPinnedDialogs#5b51d63f flags:# force:flags.0?true order:Vector = Bool; -messages.getPinnedDialogs#e254d64e = messages.PeerDialogs; +messages.reorderPinnedDialogs#3b1adf37 flags:# force:flags.0?true folder_id:int order:Vector = Bool; +messages.getPinnedDialogs#d6b94df2 folder_id:int = messages.PeerDialogs; messages.setBotShippingResults#e5f672fa flags:# query_id:long error:flags.0?string shipping_options:flags.1?Vector = Bool; messages.setBotPrecheckoutResults#9c2dd95 flags:# success:flags.1?true query_id:long error:flags.0?string = Bool; messages.uploadMedia#519bc2b1 peer:InputPeer media:InputMedia = MessageMedia; @@ -1448,4 +1458,7 @@ langpack.getDifference#cd984aa5 lang_pack:string lang_code:string from_version:i langpack.getLanguages#42c6978f lang_pack:string = Vector; langpack.getLanguage#6a596502 lang_pack:string lang_code:string = LangPackLanguage; -// LAYER 98 +folders.editPeerFolders#6847d0ab folder_peers:Vector = Updates; +folders.deleteFolder#1c295881 folder_id:int = Updates; + +// LAYER 99 diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 045b1f48c..650ac53fb 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -425,9 +425,11 @@ void ApiWrap::savePinnedOrder() { // peers.push_back(MTP_inputDialogPeerFeed(MTP_int(feed->id()))); // #feed } } - auto flags = MTPmessages_ReorderPinnedDialogs::Flag::f_force; + const auto folderId = 0; + const auto flags = MTPmessages_ReorderPinnedDialogs::Flag::f_force; request(MTPmessages_ReorderPinnedDialogs( MTP_flags(flags), + MTP_int(folderId), MTP_vector(peers) )).send(); } @@ -837,7 +839,7 @@ void ApiWrap::applyFeedDialogs( "messages.dialogsNotModified in ApiWrap::applyFeedDialogs.")); return; } - + // #TODO folders auto channels = std::vector>(); dialogs.match([&](const MTPDmessages_dialogsNotModified &) { Unexpected("Type in ApiWrap::applyFeedDialogs."); @@ -855,12 +857,12 @@ void ApiWrap::applyFeedDialogs( channels.emplace_back(history->peer->asChannel()); } else { LOG(("API Error: " - "Unexpected peer in feed dialogs list.")); + "Unexpected peer in folder dialogs list.")); } } - //}, [&](const MTPDdialogFeed &) { // #feed - // LOG(("API Error: " - // "Unexpected dialogFeed in feed dialogs list.")); + }, [&](const MTPDdialogFolder &data) { + LOG(("API Error: " + "Unexpected dialogFolder in folder dialogs list.")); }); } }); @@ -2833,7 +2835,11 @@ void ApiWrap::channelRangeDifferenceDone( _session->data().processUsers(d.vusers); _session->data().processChats(d.vchats); - nextRequestPts = d.vpts.v; + nextRequestPts = d.vdialog.match([&](const MTPDdialog &data) { + return data.has_pts() ? data.vpts.v : 0; + }, [&](const MTPDdialogFolder &data) { + return 0; + }); isFinal = d.is_final(); } break; @@ -2847,7 +2853,7 @@ void ApiWrap::channelRangeDifferenceDone( } break; } - if (!isFinal) { + if (!isFinal && nextRequestPts) { MTP_LOG(0, ("getChannelDifference { " "good - after not final channelDifference was received, " "validating history part }%1" diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index df8a2b388..62ccce107 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -964,13 +964,14 @@ void DialogsWidget::loadDialogs() { const auto firstLoad = !_dialogsOffsetDate; const auto loadCount = firstLoad ? kDialogsFirstLoad : kDialogsPerPage; - const auto flags = MTPmessages_GetDialogs::Flag::f_exclude_pinned; - const auto feedId = 0; + const auto flags = MTPmessages_GetDialogs::Flag::f_exclude_pinned + | MTPmessages_GetDialogs::Flag::f_folder_id; + const auto folderId = 0; const auto hash = 0; _dialogsRequestId = MTP::send( MTPmessages_GetDialogs( MTP_flags(flags), - //MTP_int(feedId), // #feed + MTP_int(folderId), MTP_int(_dialogsOffsetDate), MTP_int(_dialogsOffsetId), _dialogsOffsetPeer @@ -990,7 +991,7 @@ void DialogsWidget::loadPinnedDialogs() { if (_pinnedDialogsRequestId) return; _pinnedDialogsReceived = false; - _pinnedDialogsRequestId = MTP::send(MTPmessages_GetPinnedDialogs(), rpcDone(&DialogsWidget::pinnedDialogsReceived), rpcFail(&DialogsWidget::dialogsFailed)); + _pinnedDialogsRequestId = MTP::send(MTPmessages_GetPinnedDialogs(MTP_int(0)), rpcDone(&DialogsWidget::pinnedDialogsReceived), rpcFail(&DialogsWidget::dialogsFailed)); } void DialogsWidget::searchReceived( diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index e937538fe..d7b3bbd52 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -528,6 +528,7 @@ void ApiWrap::requestDialogsCount() { const auto hash = 0; splitRequest(_startProcess->splitIndex, MTPmessages_GetDialogs( MTP_flags(0), + MTPint(), // folder_id MTP_int(offsetDate), MTP_int(offsetId), offsetPeer, @@ -1097,6 +1098,7 @@ void ApiWrap::requestDialogsSlice() { const auto hash = 0; splitRequest(splitIndex, MTPmessages_GetDialogs( MTP_flags(0), + MTPint(), // folder_id MTP_int(_dialogsProcess->offsetDate), MTP_int(_dialogsProcess->offsetId), _dialogsProcess->offsetPeer, diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 70254bafc..d9bd1cb81 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2864,60 +2864,43 @@ void MainWidget::updSetState(int32 pts, int32 date, int32 qts, int32 seq) { void MainWidget::gotChannelDifference( ChannelData *channel, - const MTPupdates_ChannelDifference &diff) { + const MTPupdates_ChannelDifference &difference) { _channelFailDifferenceTimeout.remove(channel); - int32 timeout = 0; - bool isFinal = true; - switch (diff.type()) { - case mtpc_updates_channelDifferenceEmpty: { - auto &d = diff.c_updates_channelDifferenceEmpty(); - if (d.has_timeout()) timeout = d.vtimeout.v; - isFinal = d.is_final(); - channel->ptsInit(d.vpts.v); - } break; - - case mtpc_updates_channelDifferenceTooLong: { - auto &d = diff.c_updates_channelDifferenceTooLong(); - - session().data().processUsers(d.vusers); - session().data().processChats(d.vchats); - auto history = session().data().historyLoaded(channel->id); + const auto timeout = difference.match([&](const auto &data) { + return data.has_timeout() ? data.vtimeout.v : 0; + }); + const auto isFinal = difference.match([&](const auto &data) { + return data.is_final(); + }); + difference.match([&](const MTPDupdates_channelDifferenceEmpty &data) { + channel->ptsInit(data.vpts.v); + }, [&](const MTPDupdates_channelDifferenceTooLong &data) { + session().data().processUsers(data.vusers); + session().data().processChats(data.vchats); + const auto history = session().data().historyLoaded(channel->id); if (history) { history->setNotLoadedAtBottom(); - } - App::feedMsgs(d.vmessages, NewMessageLast); - if (history) { - history->applyDialogFields( - d.vunread_count.v, - d.vread_inbox_max_id.v, - d.vread_outbox_max_id.v); - history->applyDialogTopMessage(d.vtop_message.v); - history->setUnreadMentionsCount(d.vunread_mentions_count.v); - if (_history->peer() == channel) { - _history->updateHistoryDownVisibility(); - _history->preloadHistoryIfNeeded(); - } session().api().requestChannelRangeDifference(history); } - - if (d.has_timeout()) { - timeout = d.vtimeout.v; + App::feedMsgs(data.vmessages, NewMessageLast); + data.vdialog.match([&](const MTPDdialog &data) { + if (data.has_pts()) { + channel->ptsInit(data.vpts.v); + } + if (history) { + history->applyDialog(data); + } + }, [&](const MTPDdialogFolder &) { + }); + if (_history->peer() == channel) { + _history->updateHistoryDownVisibility(); + _history->preloadHistoryIfNeeded(); } - isFinal = d.is_final(); - channel->ptsInit(d.vpts.v); - } break; - - case mtpc_updates_channelDifference: { - auto &d = diff.c_updates_channelDifference(); - - feedChannelDifference(d); - - if (d.has_timeout()) timeout = d.vtimeout.v; - isFinal = d.is_final(); - channel->ptsInit(d.vpts.v); - } break; - } + }, [&](const MTPDupdates_channelDifference &data) { + feedChannelDifference(data); + channel->ptsInit(data.vpts.v); + }); channel->ptsSetRequesting(false); @@ -4016,15 +3999,18 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { case mtpc_updateDialogUnreadMark: { const auto &data = update.c_updateDialogUnreadMark(); - const auto history = data.vpeer.match( - [&](const MTPDdialogPeer &data) { - const auto peerId = peerFromMTP(data.vpeer); - return session().data().historyLoaded(peerId); - //}, [&](const MTPDdialogPeerFeed &data) { // #feed + data.vpeer.match( + [&](const MTPDdialogPeer &dialog) { + const auto id = peerFromMTP(dialog.vpeer); + if (const auto history = session().data().historyLoaded(id)) { + history->setUnreadMark(data.is_unread()); + } + }, [&](const MTPDdialogPeerFolder &dialog) { + const auto id = dialog.vfolder_id.v; // #TODO archive + //if (const auto folder = session().data().folderLoaded(id)) { + // folder->setUnreadMark(data.is_unread()); + //} }); - if (history) { - history->setUnreadMark(data.is_unread()); - } } break; // Deleted messages. diff --git a/Telegram/SourceFiles/mtproto/connection.cpp b/Telegram/SourceFiles/mtproto/connection.cpp index 1ea5d06ab..579712991 100644 --- a/Telegram/SourceFiles/mtproto/connection.cpp +++ b/Telegram/SourceFiles/mtproto/connection.cpp @@ -2176,7 +2176,7 @@ ConnectionPrivate::HandleResult ConnectionPrivate::handleOneReceived(const mtpPr && cons != mtpc_updatesCombined && cons != mtpc_updates) { // Maybe some new unknown update? - LOG(("Message Error: unknown constructor %1").arg(cons)); + LOG(("Message Error: unknown constructor 0x%1").arg(cons, 0, 16)); } } else { LOG(("Message Error: unexpected updates in dcType: %1").arg(static_cast(_dcType)));