From 99f4abb249bb3e0d3ec786d24e9eb5eccca12065 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 7 Oct 2019 22:51:03 +0300 Subject: [PATCH] Update to layer 102. Replace LinkState with is_contact/is_mutual_contact. GitOrigin-RevId: 33061b18ac72711f4df168fb27497bccb36d3367 --- td/generate/scheme/td_api.tl | 17 +- td/generate/scheme/td_api.tlo | Bin 160740 -> 160516 bytes td/generate/scheme/telegram_api.tl | 39 +++-- td/generate/scheme/telegram_api.tlo | Bin 187688 -> 189292 bytes td/telegram/ContactsManager.cpp | 245 ++++++++-------------------- td/telegram/ContactsManager.h | 27 +-- td/telegram/MessageEntity.cpp | 7 - td/telegram/MessagesManager.cpp | 27 +-- td/telegram/UpdatesManager.cpp | 11 +- td/telegram/UpdatesManager.h | 5 +- td/telegram/Version.h | 2 +- 11 files changed, 125 insertions(+), 255 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index e5ee29fd3..63b5c0b6d 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -264,18 +264,6 @@ profilePhoto id:int64 small:file big:file = ProfilePhoto; chatPhoto small:file big:file = ChatPhoto; -//@class LinkState @description Represents the relationship between user A and user B. For incoming_link, user A is the current user; for outgoing_link, user B is the current user - -//@description The phone number of user A is not known to user B -linkStateNone = LinkState; - -//@description The phone number of user A is known but that number has not been saved to the contact list of user B -linkStateKnowsPhoneNumber = LinkState; - -//@description The phone number of user A has been saved to the contact list of user B -linkStateIsContact = LinkState; - - //@class UserType @description Represents the type of the user. The following types are possible: regular users, deleted users and bots //@description A regular user @@ -302,13 +290,14 @@ botInfo description:string commands:vector = BotInfo; //@description Represents a user @id User identifier @first_name First name of the user @last_name Last name of the user @username Username of the user //@phone_number Phone number of the user @status Current online status of the user @profile_photo Profile photo of the user; may be null -//@outgoing_link Relationship from the current user to the other user @incoming_link Relationship from the other user to the current user +//@is_contact The user is a contact of the current user +//@is_mutual_contact The user is a contact of the current user and the current user is a contact of the user //@is_verified True, if the user is verified @is_support True, if the user is Telegram support account //@restriction_reason If non-empty, it contains the reason why access to this user must be restricted. The format of the string is "{type}: {description}". //-{type} contains the type of the restriction and at least one of the suffixes "-all", "-ios", "-android", or "-wp", which describe the platforms on which access should be restricted. (For example, "terms-ios-android". {description} contains a human-readable description of the restriction, which can be shown to the user) //@is_scam True, if many users reported this user as a scam //@have_access If false, the user is inaccessible, and the only information known about the user is inside this class. It can't be passed to any method except GetUser @type Type of the user @language_code IETF language tag of the user's language; only available to bots -user id:int32 first_name:string last_name:string username:string phone_number:string status:UserStatus profile_photo:profilePhoto outgoing_link:LinkState incoming_link:LinkState is_verified:Bool is_support:Bool restriction_reason:string is_scam:Bool have_access:Bool type:UserType language_code:string = User; +user id:int32 first_name:string last_name:string username:string phone_number:string status:UserStatus profile_photo:profilePhoto is_contact:Bool is_mutual_contact:Bool is_verified:Bool is_support:Bool restriction_reason:string is_scam:Bool have_access:Bool type:UserType language_code:string = User; //@description Contains full information about a user (except the full list of profile photos) @is_blocked True, if the user is blacklisted by the current user @can_be_called True, if the user can be called @has_private_calls True, if the user can't be called due to their privacy settings //@bio A short user bio @share_text For bots, the text that is included with the link when users share the bot @group_in_common_count Number of group chats where both the other user and the current user are a member; 0 for the current user @bot_info If the user is a bot, information about the bot; may be null diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 66eee5b97b4921cc5cee2862f949666e8e2362cc..3ef10aaeddd09dfea6b9e25191c663b05f1602d9 100644 GIT binary patch delta 256 zcmaFzoU`Q_C-0-#`c@23@NpyWccINX!bgNT!~a}6#}ZncS~PhghxBF<^(#z_FE+o_ z+`ndX!u6UZ)A!Udx@^Bw&G>+6TRo$W6bnfCc7vIWI-&w#ouxpXKtsX8IqMi%7`eGJ zi{q2?^GXtvOD6v}krWgJ@^ec|N)vOS!jm696Q8VbmSeg@7Nf%SC+is>KukTcfpJ5; z1jwYD$Ao-9E-i9q)8VjfI|w#?f&kMFe%#Ut3QQXq!3IsAP{3#aG15bcX-*&jD<*5O delta 467 zcmZp9#`)wqC-0-#`c@23@M$COcOl;QhB2==eKPa1gG&-iCM$|dZ)OobBFy5qB93|U z8MQA=jITEz)ZD+OzJJYD3*H>4x>UdXyi^7TklvfegnU2-7CE!&aM-pT1c||HxGKjL zGo5>jm?T`EcV2#ZaX+k4hBvM{>v=9iYF=V#`n z$AfHx_ygTn($DT|@@D2G=jUQqH$5Pe(O^2udd3G33ty~f+z>ATvIIS>z!q=dXWGG! aTe?A>X#*qJpy?a(84VytW+*bv2?PM?m!4Vx diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index 0cca35ee8..f194ced8c 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -110,11 +110,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 scam:flags.19?true has_link:flags.20?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 has_link:flags.20?true has_geo:flags.21?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#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#9882e516 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 linked_chat_id:flags.13?int pts:int = ChatFull; +channelFull#10916653 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 can_set_location:flags.16?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 linked_chat_id:flags.14?int location:flags.15?ChannelLocation pts:int = ChatFull; chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant; chatParticipantCreator#da13538a user_id:int = ChatParticipant; @@ -196,7 +196,7 @@ inputPeerNotifySettings#9c3d198e flags:# show_previews:flags.0?Bool silent:flags peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = PeerNotifySettings; -peerSettings#818426cd flags:# report_spam:flags.0?true = PeerSettings; +peerSettings#818426cd flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true = PeerSettings; wallPaper#a437c3ed id:long flags:# creator:flags.0?true default:flags.1?true pattern:flags.3?true dark:flags.4?true access_hash:long slug:string document:Document settings:flags.2?WallPaperSettings = WallPaper; @@ -206,8 +206,9 @@ inputReportReasonPornography#2e59d922 = ReportReason; inputReportReasonChildAbuse#adf44ee3 = ReportReason; inputReportReasonOther#e1746d0a text:string = ReportReason; inputReportReasonCopyright#9b89f93a = ReportReason; +inputReportReasonGeoIrrelevant#dbd4feed = ReportReason; -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; +userFull#edf17c12 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 settings:PeerSettings 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; @@ -217,8 +218,6 @@ contactBlocked#561bc879 user_id:int date:int = ContactBlocked; contactStatus#d3680c61 user_id:int status:UserStatus = ContactStatus; -contacts.link#3ace484c my_link:ContactLink foreign_link:ContactLink user:User = contacts.Link; - contacts.contactsNotModified#b74ba9d2 = contacts.Contacts; contacts.contacts#eae87e42 contacts:Vector saved_count:int users:Vector = contacts.Contacts; @@ -269,7 +268,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; -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; updateEncryption#b4a2e88d chat:EncryptedChat date:int = Update; @@ -330,6 +328,8 @@ 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; +updatePeerSettings#6a7e7366 peer:Peer settings:PeerSettings = Update; +updatePeerLocated#b4afcfb0 peers:Vector = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -475,10 +475,6 @@ messages.allStickers#edfd405f hash:int sets:Vector = messages.AllSti messages.affectedMessages#84d19185 pts:int pts_count:int = messages.AffectedMessages; -contactLinkUnknown#5f4f9247 = ContactLink; -contactLinkNone#feedd3ad = ContactLink; -contactLinkContact#d502c2d0 = ContactLink; - webPageEmpty#eb1477e8 id:long = WebPage; webPagePending#c586da1c id:long date:int = WebPage; webPage#5f07b4bc flags:# id:long url:string display_url:string hash:int type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document cached_page:flags.10?Page = WebPage; @@ -838,6 +834,7 @@ channelAdminLogEventActionTogglePreHistoryHidden#5f5c95f1 new_value:Bool = Chann channelAdminLogEventActionDefaultBannedRights#2df5fc0a prev_banned_rights:ChatBannedRights new_banned_rights:ChatBannedRights = ChannelAdminLogEventAction; channelAdminLogEventActionStopPoll#8f079643 message:Message = ChannelAdminLogEventAction; channelAdminLogEventActionChangeLinkedChat#a26f881b prev_value:int new_value:int = ChannelAdminLogEventAction; +channelAdminLogEventActionChangeLocation#e6b76ae prev_value:ChannelLocation new_value:ChannelLocation = ChannelAdminLogEventAction; channelAdminLogEvent#3b5a3e40 id:long date:int user_id:int action:ChannelAdminLogEventAction = ChannelAdminLogEvent; @@ -1048,6 +1045,11 @@ urlAuthResultRequest#92d33a0e flags:# request_write_access:flags.0?true bot:User urlAuthResultAccepted#8f8c0e4e url:string = UrlAuthResult; urlAuthResultDefault#a9d6db1f = UrlAuthResult; +channelLocationEmpty#bfb5ad8b = ChannelLocation; +channelLocation#209b82db geo_point:GeoPoint address:string = ChannelLocation; + +peerLocated#ca461b5d peer:Peer expires:int distance:int = PeerLocated; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1138,8 +1140,7 @@ contacts.getContactIDs#2caa4a42 hash:int = Vector; contacts.getStatuses#c4a353ee = Vector; contacts.getContacts#c023849f hash:int = contacts.Contacts; contacts.importContacts#2c800be5 contacts:Vector = contacts.ImportedContacts; -contacts.deleteContact#8e953744 id:InputUser = contacts.Link; -contacts.deleteContacts#59ab389e id:Vector = Bool; +contacts.deleteContacts#96a0e00 id:Vector = Updates; contacts.deleteByPhones#1013fd9e phones:Vector = Bool; contacts.block#332b49fc id:InputUser = Bool; contacts.unblock#e54100bd id:InputUser = Bool; @@ -1151,6 +1152,8 @@ contacts.resetTopPeerRating#1ae373ac category:TopPeerCategory peer:InputPeer = B contacts.resetSaved#879537f1 = Bool; contacts.getSaved#82f1e39f = Vector; contacts.toggleTopPeers#8514bdda enabled:Bool = Bool; +contacts.addContact#e8f463d0 flags:# add_phone_privacy_exception:flags.0?true id:InputUser first_name:string last_name:string phone:string = Updates; +contacts.getLocated#a356056 geo_point:InputGeoPoint = Updates; 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; @@ -1165,7 +1168,6 @@ messages.sendMessage#fa88427a flags:# no_webpage:flags.1?true silent:flags.5?tru messages.sendMedia#b8d1262b flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector = Updates; messages.forwardMessages#708e0195 flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true grouped:flags.9?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer = Updates; messages.reportSpam#cf1592db peer:InputPeer = Bool; -messages.hideReportSpam#a8f1709b peer:InputPeer = Bool; messages.getPeerSettings#3672e09c peer:InputPeer = PeerSettings; messages.report#bd82b658 peer:InputPeer id:Vector reason:ReportReason = Bool; messages.getChats#3c6aa187 id:Vector = messages.Chats; @@ -1200,7 +1202,7 @@ messages.startBot#e6df7378 bot:InputUser peer:InputPeer random_id:long start_par messages.getMessagesViews#c4c8a55d peer:InputPeer id:Vector increment:Bool = Vector; messages.editChatAdmin#a9e69f2e chat_id:int user_id:InputUser is_admin:Bool = Bool; messages.migrateChat#15a3b8e3 chat_id:int = Updates; -messages.searchGlobal#f79c611 q:string offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; +messages.searchGlobal#bf7225a4 flags:# folder_id:flags.0?int q:string 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.searchGifs#bf9a776b q:string offset:int = messages.FoundGifs; @@ -1265,6 +1267,7 @@ messages.getEmojiURL#d5b10c26 lang_code:string = EmojiURL; messages.getSearchCounters#732eef00 peer:InputPeer filters:Vector = Vector; messages.requestUrlAuth#e33f5613 peer:InputPeer msg_id:int button_id:int = UrlAuthResult; messages.acceptUrlAuth#f729ea98 flags:# write_allowed:flags.0?true peer:InputPeer msg_id:int button_id:int = UrlAuthResult; +messages.hidePeerSettingsBar#4facb138 peer:InputPeer = Bool; updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; @@ -1313,7 +1316,7 @@ channels.getParticipants#123e05e9 channel:InputChannel filter:ChannelParticipant channels.getParticipant#546dd7a6 channel:InputChannel user_id:InputUser = channels.ChannelParticipant; channels.getChannels#a7f6bbb id:Vector = messages.Chats; channels.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull; -channels.createChannel#f4893d7f flags:# broadcast:flags.0?true megagroup:flags.1?true title:string about:string = Updates; +channels.createChannel#3d5fb10f flags:# broadcast:flags.0?true megagroup:flags.1?true title:string about:string geo_point:flags.2?InputGeoPoint address:flags.2?string = Updates; channels.editAdmin#70f893ba channel:InputChannel user_id:InputUser admin_rights:ChatAdminRights = Updates; channels.editTitle#566decd0 channel:InputChannel title:string = Updates; channels.editPhoto#f12e57c9 channel:InputChannel photo:InputChatPhoto = Updates; @@ -1325,7 +1328,7 @@ channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector = channels.deleteChannel#c0111fe3 channel:InputChannel = Updates; channels.exportMessageLink#ceb77163 channel:InputChannel id:int grouped:Bool = ExportedMessageLink; channels.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates; -channels.getAdminedPublicChannels#8d8d82d7 = messages.Chats; +channels.getAdminedPublicChannels#f8b036af flags:# by_location:flags.0?true check_limit:flags.1?true = messages.Chats; channels.editBanned#72796912 channel:InputChannel user_id:InputUser banned_rights:ChatBannedRights = Updates; channels.getAdminLog#33ddf480 flags:# channel:InputChannel q:string events_filter:flags.0?ChannelAdminLogEventsFilter admins:flags.1?Vector max_id:long min_id:long limit:int = channels.AdminLogResults; channels.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet = Bool; @@ -1335,6 +1338,8 @@ channels.togglePreHistoryHidden#eabbb94c channel:InputChannel enabled:Bool = Upd channels.getLeftChannels#8341ecc0 offset:int = messages.Chats; channels.getGroupsForDiscussion#f5dad378 = messages.Chats; channels.setDiscussionGroup#40582bb2 broadcast:InputChannel group:InputChannel = Bool; +channels.editCreator#8f38cd1f channel:InputChannel user_id:InputUser password:InputCheckPasswordSRP = Updates; +channels.editLocation#58e63f6d channel:InputChannel geo_point:InputGeoPoint address:string = Bool; bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index de4f025ed073f9b6b33d7d8910924df43841e153..672e48ddb266e34d60eb9498231d127a3a8f82e8 100644 GIT binary patch delta 4052 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 GF#Hb!k7-x{ diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index a7afbc6ac..f6bc2c329 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -588,14 +588,12 @@ class ImportContactsQuery : public Td::ResultHandler { class DeleteContactsQuery : public Td::ResultHandler { Promise promise_; - vector user_ids_; public: explicit DeleteContactsQuery(Promise &&promise) : promise_(std::move(promise)) { } void send(vector &&user_ids, vector> &&input_users) { - user_ids_ = std::move(user_ids); send_query( G()->net_query_creator().create(create_storer(telegram_api::contacts_deleteContacts(std::move(input_users))))); } @@ -606,12 +604,10 @@ class DeleteContactsQuery : public Td::ResultHandler { return on_error(id, result_ptr.move_as_error()); } - bool result = result_ptr.ok(); - if (!result) { - return on_error(id, Status::Error(500, "Some contacts can't be deleted")); - } + auto ptr = result_ptr.move_as_ok(); + LOG(INFO) << "Receive result for DeleteContactsQuery: " << to_string(ptr); + td->updates_manager_->on_get_updates(std::move(ptr)); - td->contacts_manager_->on_deleted_contacts(user_ids_); promise_.set_value(Unit()); } @@ -2327,24 +2323,6 @@ class GetSupportUserQuery : public Td::ResultHandler { } }; -StringBuilder &operator<<(StringBuilder &string_builder, ContactsManager::LinkState link_state) { - switch (link_state) { - case ContactsManager::LinkState::Unknown: - string_builder << "unknown"; - break; - case ContactsManager::LinkState::None: - string_builder << "none"; - break; - case ContactsManager::LinkState::KnowsPhoneNumber: - string_builder << "knows phone number"; - break; - case ContactsManager::LinkState::Contact: - string_builder << "contact"; - break; - } - return string_builder; -} - bool ContactsManager::UserFull::is_bot_info_expired(int32 bot_info_version) const { return bot_info_version != -1 && (bot_info == nullptr || bot_info->version != bot_info_version); } @@ -2483,18 +2461,6 @@ void ContactsManager::on_channel_unban_timeout(ChannelId channel_id) { update_channel(c, channel_id); // always call, because in case of failure we need to reactivate timeout } -template -void ContactsManager::store_link_state(const LinkState &link_state, StorerT &storer) { - store(static_cast(link_state), storer); -} - -template -void ContactsManager::parse_link_state(LinkState &link_state, ParserT &parser) { - uint32 link_state_uint32; - parse(link_state_uint32, parser); - link_state = static_cast(static_cast(link_state_uint32)); -} - template void ContactsManager::BotInfo::store(StorerT &storer) const { using td::store; @@ -2541,6 +2507,7 @@ void ContactsManager::User::store(StorerT &storer) const { bool has_language_code = !language_code.empty(); bool have_access_hash = access_hash != -1; bool has_cache_version = cache_version != 0; + bool has_is_contact = true; BEGIN_STORE_FLAGS(); STORE_FLAG(is_received); STORE_FLAG(is_verified); @@ -2560,6 +2527,9 @@ void ContactsManager::User::store(StorerT &storer) const { STORE_FLAG(is_min_access_hash); STORE_FLAG(is_scam); STORE_FLAG(has_cache_version); + STORE_FLAG(has_is_contact); + STORE_FLAG(is_contact); + STORE_FLAG(is_mutual_contact); END_STORE_FLAGS(); store(first_name, storer); if (has_last_name) { @@ -2575,8 +2545,6 @@ void ContactsManager::User::store(StorerT &storer) const { if (has_photo) { store(photo, storer); } - store_link_state(inbound, storer); - store_link_state(outbound, storer); store(was_online, storer); if (is_restricted) { store(restriction_reason, storer); @@ -2605,6 +2573,7 @@ void ContactsManager::User::parse(ParserT &parser) { bool has_language_code; bool have_access_hash; bool has_cache_version; + bool has_is_contact; BEGIN_PARSE_FLAGS(); PARSE_FLAG(is_received); PARSE_FLAG(is_verified); @@ -2624,6 +2593,9 @@ void ContactsManager::User::parse(ParserT &parser) { PARSE_FLAG(is_min_access_hash); PARSE_FLAG(is_scam); PARSE_FLAG(has_cache_version); + PARSE_FLAG(has_is_contact); + PARSE_FLAG(is_contact); + PARSE_FLAG(is_mutual_contact); END_PARSE_FLAGS(); parse(first_name, parser); if (has_last_name) { @@ -2642,8 +2614,17 @@ void ContactsManager::User::parse(ParserT &parser) { if (has_photo) { parse(photo, parser); } - parse_link_state(inbound, parser); - parse_link_state(outbound, parser); + if (!has_is_contact) { + // enum class LinkState : uint8 { Unknown, None, KnowsPhoneNumber, Contact }; + + uint32 link_state_inbound; + uint32 link_state_outbound; + parse(link_state_inbound, parser); + parse(link_state_outbound, parser); + + is_contact = link_state_outbound == 3; + is_mutual_contact = is_contact && link_state_inbound == 3; + } parse(was_online, parser); if (is_restricted) { parse(restriction_reason, parser); @@ -3485,7 +3466,7 @@ bool ContactsManager::default_can_report_spam_in_secret_chat(SecretChatId secret if (u == nullptr) { return true; } - if (u->outbound == LinkState::Contact) { + if (u->is_contact) { return false; } return true; @@ -3939,7 +3920,7 @@ int32 ContactsManager::get_contacts_hash() { CHECK(std::is_sorted(user_ids.begin(), user_ids.end())); auto my_id = get_my_id(); const User *u = get_user_force(my_id); - if (u != nullptr && u->outbound == LinkState::Contact) { + if (u != nullptr && u->is_contact) { user_ids.insert(std::upper_bound(user_ids.begin(), user_ids.end(), my_id.get()), my_id.get()); } @@ -4010,7 +3991,7 @@ void ContactsManager::remove_contacts(vector user_ids, Promise &&p vector> input_users; for (auto &user_id : user_ids) { const User *u = get_user(user_id); - if (u != nullptr && u->outbound == LinkState::Contact) { + if (u != nullptr && u->is_contact) { auto input_user = get_input_user(user_id); if (input_user != nullptr) { to_delete_user_ids.push_back(user_id); @@ -4281,15 +4262,14 @@ void ContactsManager::on_update_contacts_reset() { for (auto &p : users_) { UserId user_id = p.first; User u = &p.second; - bool is_contact = u->outbound == LinkState::Contact; - if (is_contact) { + if (u->is_contact) { LOG(INFO) << "Drop contact with " << user_id; if (user_id != my_id) { CHECK(contacts_hints_.has_key(user_id.get())); } - on_update_user_links(u, user_id, LinkState::KnowsPhoneNumber, u->inbound); + on_update_user_is_contact(u, user_id, false, false); update_user(u, user_id); - CHECK(u->outbound != LinkState::Contact); + CHECK(!u->is_contact); if (user_id != my_id) { CHECK(!contacts_hints_.has_key(user_id.get())); } @@ -5366,9 +5346,9 @@ void ContactsManager::on_deleted_contacts(const vector &deleted_contact_ LOG(INFO) << "Drop contact with " << user_id; auto u = get_user(user_id); CHECK(u != nullptr); - on_update_user_links(u, user_id, LinkState::KnowsPhoneNumber, u->inbound); + on_update_user_is_contact(u, user_id, false, false); update_user(u, user_id); - CHECK(u->outbound != LinkState::Contact); + CHECK(!u->is_contact); CHECK(!contacts_hints_.has_key(user_id.get())); } } @@ -5409,18 +5389,17 @@ void ContactsManager::on_get_contacts(tl_object_ptroutbound == LinkState::Contact; bool should_be_contact = contact_user_ids.count(user_id) == 1; - if (is_contact != should_be_contact) { - if (is_contact) { + if (u->is_contact != should_be_contact) { + if (u->is_contact) { LOG(INFO) << "Drop contact with " << user_id; if (user_id != my_id) { LOG_CHECK(contacts_hints_.has_key(user_id.get())) << my_id << " " << user_id << " " << to_string(get_user_object(user_id, u)); } - on_update_user_links(u, user_id, LinkState::KnowsPhoneNumber, u->inbound); + on_update_user_is_contact(u, user_id, false, false); update_user(u, user_id); - CHECK(u->outbound != LinkState::Contact); + CHECK(!u->is_contact); if (user_id != my_id) { CHECK(!contacts_hints_.has_key(user_id.get())); } @@ -5522,12 +5501,6 @@ void ContactsManager::on_update_online_status_privacy() { td_->create_handler()->send(); } -void ContactsManager::on_get_contacts_link(tl_object_ptr &&link) { - UserId user_id = get_user_id(link->user_); - on_get_user(std::move(link->user_), "on_get_contacts_link"); - on_update_user_links(user_id, std::move(link->my_link_), std::move(link->foreign_link_)); -} - UserId ContactsManager::get_user_id(const tl_object_ptr &user) { CHECK(user != nullptr); switch (user->get_id()) { @@ -5643,21 +5616,9 @@ void ContactsManager::on_get_user(tl_object_ptr &&user_ptr, if (is_received) { on_update_user_online(u, user_id, std::move(user->status_)); - LinkState out, in; - if (flags & USER_FLAG_IS_MUTUAL_CONTACT) { - out = LinkState::Contact; - in = LinkState::Contact; - } else if (flags & USER_FLAG_IS_CONTACT) { - out = LinkState::Contact; - in = LinkState::Unknown; - } else if (flags & USER_FLAG_HAS_PHONE_NUMBER) { - out = LinkState::KnowsPhoneNumber; - in = LinkState::Unknown; - } else { - out = LinkState::None; - in = LinkState::Unknown; - } - on_update_user_links(u, user_id, out, in); + auto is_contact = (flags & USER_FLAG_IS_CONTACT) != 0; + auto is_mutual_contact = (flags & USER_FLAG_IS_MUTUAL_CONTACT) != 0; + on_update_user_is_contact(u, user_id, is_contact, is_mutual_contact); } if (is_received || !u->is_received) { @@ -5875,7 +5836,7 @@ void ContactsManager::on_save_user_to_database(UserId user_id, bool success) { << u->is_deleted << " " << u->is_bot << " " << u->is_changed << " " << u->need_send_update << " " << u->is_status_changed << " " << u->is_name_changed << " " << u->is_username_changed << " " << u->is_photo_changed << " " - << u->is_outbound_link_changed; + << u->is_is_contact_changed; CHECK(load_user_from_database_queries_.count(user_id) == 0); u->is_being_saved = false; @@ -6911,7 +6872,7 @@ ContactsManager::ChannelFull *ContactsManager::get_channel_full_force(ChannelId void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, bool from_database) { CHECK(u != nullptr); - if (u->is_name_changed || u->is_username_changed || u->is_outbound_link_changed) { + if (u->is_name_changed || u->is_username_changed || u->is_is_contact_changed) { update_contacts_hints(u, user_id, from_database); } if (u->is_name_changed) { @@ -6963,7 +6924,7 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo u->is_name_changed = false; u->is_username_changed = false; u->is_photo_changed = false; - u->is_outbound_link_changed = false; + u->is_is_contact_changed = false; u->is_default_permissions_changed = false; if (u->is_deleted) { @@ -7291,7 +7252,6 @@ void ContactsManager::on_get_user_full(tl_object_ptr &&u return; } - on_update_user_links(user_id, std::move(user_full->link_->my_link_), std::move(user_full->link_->foreign_link_)); td_->messages_manager_->on_update_dialog_notify_settings(DialogId(user_id), std::move(user_full->notify_settings_), "on_get_user_full"); @@ -7695,7 +7655,7 @@ void ContactsManager::on_get_chat_full(tl_object_ptr &&c bool ContactsManager::is_update_about_username_change_received(UserId user_id) const { const User *u = get_user(user_id); if (u != nullptr) { - return u->inbound == LinkState::Contact; + return u->is_contact; } else { return false; } @@ -7830,6 +7790,26 @@ void ContactsManager::add_user_photo_id(User *u, UserId user_id, int64 photo_id, } } +void ContactsManager::on_update_user_is_contact(User *u, UserId user_id, bool is_contact, bool is_mutual_contact) { + UserId my_id = get_my_id(); + if (user_id == my_id) { + is_mutual_contact = is_contact; + } + if (!is_contact && is_mutual_contact) { + LOG(ERROR) << "Receive is_mutual_contact == true for non-contact " << user_id; + is_mutual_contact = false; + } + + if (u->is_contact != is_contact || u->is_mutual_contact != is_mutual_contact) { + LOG(DEBUG) << "Update " << user_id << " is_contact from (" << u->is_contact << ", " << u->is_mutual_contact + << ") to (" << is_contact << ", " << is_mutual_contact << ")"; + u->is_is_contact_changed |= (u->is_contact != is_contact); + u->is_contact = is_contact; + u->is_mutual_contact = is_mutual_contact; + u->need_send_update = true; + } +} + void ContactsManager::on_update_user_online(UserId user_id, tl_object_ptr &&status) { if (!user_id.is_valid()) { LOG(ERROR) << "Receive invalid " << user_id; @@ -8024,77 +8004,6 @@ void ContactsManager::on_delete_profile_photo(int64 profile_photo_id, Promise &&link) { - int32 id = link->get_id(); - switch (id) { - case telegram_api::contactLinkUnknown::ID: - return LinkState::Unknown; - case telegram_api::contactLinkNone::ID: - return LinkState::None; - case telegram_api::contactLinkContact::ID: - return LinkState::Contact; - default: - UNREACHABLE(); - } - return LinkState::Unknown; -} - -void ContactsManager::on_update_user_links(UserId user_id, tl_object_ptr &&outbound, - tl_object_ptr &&inbound) { - if (!user_id.is_valid()) { - LOG(ERROR) << "Receive invalid " << user_id; - return; - } - - User *u = get_user_force(user_id); - if (u != nullptr) { - on_update_user_links(u, user_id, get_link_state(std::move(outbound)), get_link_state(std::move(inbound))); - update_user(u, user_id); - } else { - LOG(INFO) << "Ignore update user links about unknown " << user_id; - } -} - -void ContactsManager::on_update_user_links(User *u, UserId user_id, LinkState outbound, LinkState inbound) { - UserId my_id = get_my_id(); - if (user_id == my_id) { - if (outbound == LinkState::None && !td_->auth_manager_->is_bot()) { - outbound = LinkState::KnowsPhoneNumber; - } - inbound = outbound; - } - if (!u->phone_number.empty() && outbound == LinkState::None) { - outbound = LinkState::KnowsPhoneNumber; - } - - LOG(DEBUG) << "Update " << user_id << " links from (" << u->outbound << ", " << u->inbound << ") to (" << outbound - << ", " << inbound << ")"; - bool need_send_update = false; - if (outbound != u->outbound && outbound != LinkState::Unknown) { - need_send_update |= outbound != LinkState::None || u->outbound != LinkState::Unknown; - LOG(DEBUG) << "Set outbound link to " << outbound << ", need_send_update = " << need_send_update; - u->outbound = outbound; - u->is_outbound_link_changed = true; - u->is_changed = true; - } - if (inbound != u->inbound && inbound != LinkState::Unknown) { - need_send_update |= inbound != LinkState::None || u->inbound != LinkState::Unknown; - LOG(DEBUG) << "Set inbound link to " << inbound << ", need_send_update = " << need_send_update; - u->inbound = inbound; - u->is_changed = true; - } - if (u->inbound == LinkState::Contact && u->outbound != LinkState::Contact) { - u->inbound = LinkState::KnowsPhoneNumber; - u->is_changed = true; - need_send_update = true; - } - - if (need_send_update) { - LOG(DEBUG) << "Links have changed for " << user_id; - u->need_send_update = true; - } -} - void ContactsManager::drop_user_full(UserId user_id) { auto user_full = get_user_full_force(user_id); if (user_full == nullptr) { @@ -8433,7 +8342,7 @@ bool ContactsManager::is_user_contact(UserId user_id) const { } bool ContactsManager::is_user_contact(const User *u, UserId user_id) const { - return u != nullptr && u->outbound == LinkState::Contact && user_id != get_my_id(); + return u != nullptr && u->is_contact && user_id != get_my_id(); } void ContactsManager::on_get_channel_participants_success( @@ -11301,9 +11210,8 @@ int32 ContactsManager::get_user_id_object(UserId user_id, const char *source) co send_closure(G()->td(), &Td::send_update, td_api::make_object(td_api::make_object( user_id.get(), "", "", "", "", td_api::make_object(), - get_profile_photo_object(td_->file_manager_.get(), nullptr), - get_link_state_object(LinkState::Unknown), get_link_state_object(LinkState::Unknown), false, false, - "", false, false, td_api::make_object(), ""))); + get_profile_photo_object(td_->file_manager_.get(), nullptr), false, false, false, false, "", false, + false, td_api::make_object(), ""))); } return user_id.get(); } @@ -11326,11 +11234,11 @@ tl_object_ptr ContactsManager::get_user_object(UserId user_id, con type = make_tl_object(); } - return make_tl_object( - user_id.get(), u->first_name, u->last_name, u->username, u->phone_number, get_user_status_object(user_id, u), - get_profile_photo_object(td_->file_manager_.get(), &u->photo), get_link_state_object(u->outbound), - get_link_state_object(u->inbound), u->is_verified, u->is_support, u->restriction_reason, u->is_scam, - u->is_received, std::move(type), u->language_code); + return make_tl_object(user_id.get(), u->first_name, u->last_name, u->username, u->phone_number, + get_user_status_object(user_id, u), + get_profile_photo_object(td_->file_manager_.get(), &u->photo), u->is_contact, + u->is_mutual_contact, u->is_verified, u->is_support, u->restriction_reason, + u->is_scam, u->is_received, std::move(type), u->language_code); } vector ContactsManager::get_user_ids_object(const vector &user_ids) const { @@ -11498,21 +11406,6 @@ tl_object_ptr ContactsManager::get_secret_chat_object_const( secret_chat->key_hash, secret_chat->layer); } -tl_object_ptr ContactsManager::get_link_state_object(LinkState link) { - switch (link) { - case LinkState::Unknown: - case LinkState::None: - return make_tl_object(); - case LinkState::KnowsPhoneNumber: - return make_tl_object(); - case LinkState::Contact: - return make_tl_object(); - default: - UNREACHABLE(); - } - return make_tl_object(); -} - tl_object_ptr ContactsManager::get_bot_info_object(const BotInfo *bot_info) { if (bot_info == nullptr) { return nullptr; diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 573f90238..584672120 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -132,8 +132,6 @@ class ContactsManager : public Actor { void reload_contacts(bool force); - void on_get_contacts_link(tl_object_ptr &&link); - void on_get_user(tl_object_ptr &&user, const char *source, bool is_me = false, bool expect_support = false); void on_get_users(vector> &&users, const char *source); @@ -160,8 +158,6 @@ class ContactsManager : public Actor { void on_update_user_photo(UserId user_id, tl_object_ptr &&photo_ptr); void on_update_user_online(UserId user_id, tl_object_ptr &&status); void on_update_user_local_was_online(UserId user_id, int32 local_was_online); - void on_update_user_links(UserId user_id, tl_object_ptr &&outbound, - tl_object_ptr &&inbound); void on_update_user_blocked(UserId user_id, bool is_blocked); void on_update_user_common_chat_count(UserId user_id, int32 common_chat_count); @@ -475,10 +471,6 @@ class ContactsManager : public Actor { void get_current_state(vector> &updates) const; private: - enum class LinkState : uint8 { Unknown, None, KnowsPhoneNumber, Contact }; - - friend StringBuilder &operator<<(StringBuilder &string_builder, LinkState link_state); - struct User { string first_name; string last_name; @@ -497,9 +489,6 @@ class ContactsManager : public Actor { string language_code; - LinkState outbound = LinkState::Unknown; - LinkState inbound = LinkState::Unknown; - std::unordered_set photo_ids; std::unordered_map online_member_dialogs; // id -> time @@ -518,6 +507,8 @@ class ContactsManager : public Actor { bool is_inline_bot = false; bool need_location_bot = false; bool is_scam = false; + bool is_contact = false; + bool is_mutual_contact = false; bool is_photo_inited = false; @@ -526,7 +517,7 @@ class ContactsManager : public Actor { bool is_name_changed = true; bool is_username_changed = true; bool is_photo_changed = true; - bool is_outbound_link_changed = true; + bool is_is_contact_changed = true; bool is_default_permissions_changed = true; bool is_changed = true; // have new changes not sent to the database except changes visible to the client bool need_send_update = true; // have new changes not sent to the client @@ -939,8 +930,6 @@ class ContactsManager : public Actor { void set_my_id(UserId my_id); - static LinkState get_link_state(tl_object_ptr &&link); - static bool is_valid_username(const string &username); bool on_update_bot_info(tl_object_ptr &&bot_info); @@ -949,9 +938,9 @@ class ContactsManager : public Actor { void on_update_user_phone_number(User *u, UserId user_id, string &&phone_number); void on_update_user_photo(User *u, UserId user_id, tl_object_ptr &&photo, const char *source); + void on_update_user_is_contact(User *u, UserId user_id, bool is_contact, bool is_mutual_contact); void on_update_user_online(User *u, UserId user_id, tl_object_ptr &&status); void on_update_user_local_was_online(User *u, UserId user_id, int32 local_was_online); - void on_update_user_links(User *u, UserId user_id, LinkState outbound, LinkState inbound); void do_update_user_photo(User *u, UserId user_id, tl_object_ptr &&photo, const char *source); @@ -1127,8 +1116,6 @@ class ContactsManager : public Actor { tl_object_ptr get_user_status_object(UserId user_id, const User *u) const; - static tl_object_ptr get_link_state_object(LinkState link); - static tl_object_ptr get_bot_info_object(const BotInfo *bot_info); tl_object_ptr get_user_object(UserId user_id, const User *u) const; @@ -1175,12 +1162,6 @@ class ContactsManager : public Actor { void on_user_online_timeout(UserId user_id); - template - static void store_link_state(const LinkState &link_state, StorerT &storer); - - template - static void parse_link_state(LinkState &link_state, ParserT &parser); - void tear_down() override; Td *td_; diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index 49601cd80..0a69a8427 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -2663,13 +2663,6 @@ Status fix_formatted_text(string &text, vector &entities, bool al entities = merge_entities(std::move(entities), find_entities(text, skip_bot_commands)); } - for (auto it = entities.begin(); it != entities.end(); ++it) { - CHECK(it->length > 0); - if (it + 1 != entities.end()) { - CHECK(it->offset + it->length <= (it + 1)->offset); - } - } - // TODO MAX_MESSAGE_LENGTH and MAX_CAPTION_LENGTH return Status::OK(); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index e1d977ff1..d5af4106b 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -599,8 +599,8 @@ class CreateChannelQuery : public Td::ResultHandler { } random_id_ = random_id; - send_query(G()->net_query_creator().create(create_storer( - telegram_api::channels_createChannel(flags, false /*ignored*/, false /*ignored*/, title, about)))); + send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_createChannel( + flags, false /*ignored*/, false /*ignored*/, title, about, nullptr, string())))); } void on_result(uint64 id, BufferSlice packet) override { @@ -1459,8 +1459,9 @@ class SearchMessagesGlobalQuery : public Td::ResultHandler { input_peer = make_tl_object(); } - send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_searchGlobal( - query, offset_date_, std::move(input_peer), offset_message_id.get_server_message_id().get(), limit)))); + send_query(G()->net_query_creator().create(create_storer( + telegram_api::messages_searchGlobal(0, false /*ignored*/, query, offset_date_, std::move(input_peer), + offset_message_id.get_server_message_id().get(), limit)))); } void on_result(uint64 id, BufferSlice packet) override { @@ -3228,22 +3229,24 @@ class UpdatePeerSettingsQuery : public Td::ResultHandler { send_query( G()->net_query_creator().create(create_storer(telegram_api::messages_reportSpam(std::move(input_peer))))); } else { - send_query( - G()->net_query_creator().create(create_storer(telegram_api::messages_hideReportSpam(std::move(input_peer))))); + send_query(G()->net_query_creator().create( + create_storer(telegram_api::messages_hidePeerSettingsBar(std::move(input_peer))))); } } void on_result(uint64 id, BufferSlice packet) override { static_assert(std::is_same::value, + telegram_api::messages_hidePeerSettingsBar::ReturnType>::value, ""); auto result_ptr = fetch_result(packet); if (result_ptr.is_error()) { return on_error(id, result_ptr.move_as_error()); } - td->messages_manager_->on_get_peer_settings(dialog_id_, - make_tl_object(0, false /*ignored*/)); + td->messages_manager_->on_get_peer_settings( + dialog_id_, + make_tl_object(0, false /*ignored*/, false /*ignored*/, false /*ignored*/, + false /*ignored*/, false /*ignored*/, false /*ignored*/)); promise_.set_value(Unit()); } @@ -3280,8 +3283,10 @@ class ReportEncryptedSpamQuery : public Td::ResultHandler { return on_error(id, result_ptr.move_as_error()); } - td->messages_manager_->on_get_peer_settings(dialog_id_, - make_tl_object(0, false /*ignored*/)); + td->messages_manager_->on_get_peer_settings( + dialog_id_, + make_tl_object(0, false /*ignored*/, false /*ignored*/, false /*ignored*/, + false /*ignored*/, false /*ignored*/, false /*ignored*/)); promise_.set_value(Unit()); } diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 048e4d8d2..84dd1e473 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -1697,11 +1697,6 @@ void UpdatesManager::on_update(tl_object_ptr up td_->contacts_manager_->on_update_user_blocked(UserId(update->user_id_), update->blocked_); } -void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { - td_->contacts_manager_->on_update_user_links(UserId(update->user_id_), std::move(update->my_link_), - std::move(update->foreign_link_)); -} - void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { td_->contacts_manager_->on_get_chat_participants(std::move(update->participants_), true); } @@ -1906,4 +1901,10 @@ void UpdatesManager::on_update(tl_object_ptr up // unsupported updates +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 c3b4b8bee..1fc6f9523 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -204,7 +204,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*/); void on_update(tl_object_ptr update, bool /*force_apply*/); void on_update(tl_object_ptr update, bool /*force_apply*/); @@ -280,6 +279,10 @@ class UpdatesManager : public Actor { void on_update(tl_object_ptr update, bool /*force_apply*/); // 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 c1c19e9bb..5bd39c770 100644 --- a/td/telegram/Version.h +++ b/td/telegram/Version.h @@ -8,7 +8,7 @@ namespace td { -constexpr int32 MTPROTO_LAYER = 101; +constexpr int32 MTPROTO_LAYER = 102; enum class Version : int32 { Initial,