Update layer to 82. Contact.vcard support.

GitOrigin-RevId: 302d65351cfaeb6b4e82c594565ab1aef18b2a42
This commit is contained in:
levlam 2018-06-26 00:10:53 +03:00
parent fa80e98227
commit aa13a57a3c
41 changed files with 334 additions and 135 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
project(TDLib VERSION 1.2.4 LANGUAGES CXX C)
project(TDLib VERSION 1.2.5 LANGUAGES CXX C)
# Prevent in-source build
get_filename_component(TD_REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)

View File

@ -117,7 +117,7 @@ target_link_libraries(YourTarget PRIVATE Td::TdStatic)
Or you could install `TDLib` and then reference it in your CMakeLists.txt like this:
```
find_package(Td 1.2.4 REQUIRED)
find_package(Td 1.2.5 REQUIRED)
target_link_libraries(YourTarget PRIVATE Td::TdStatic)
```
See [example/cpp/CMakeLists.txt](https://github.com/tdlib/td/tree/master/example/cpp/CMakeLists.txt).

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(TdExample VERSION 1.0 LANGUAGES CXX)
find_package(Td 1.2.4 REQUIRED)
find_package(Td 1.2.5 REQUIRED)
add_executable(tdjson_example tdjson_example.cpp)
target_link_libraries(tdjson_example PRIVATE Td::TdJson)

View File

@ -1,6 +1,6 @@
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
<Metadata>
<Identity Id="Telegram.Td.UWP" Version="1.2.4" Language="en-US" Publisher="Telegram LLC" />
<Identity Id="Telegram.Td.UWP" Version="1.2.5" Language="en-US" Publisher="Telegram LLC" />
<DisplayName>TDLib for Universal Windows Platform</DisplayName>
<Description>TDLib is a library for building Telegram clients</Description>
<MoreInfo>https://core.telegram.org/tdlib</MoreInfo>

View File

@ -218,8 +218,8 @@ videoNote duration:int32 length:int32 thumbnail:photoSize video:file = VideoNote
//@waveform A waveform representation of the voice note in 5-bit format @mime_type MIME type of the file; as defined by the sender @voice File containing the voice note
voiceNote duration:int32 waveform:bytes mime_type:string voice:file = VoiceNote;
//@description Describes a user contact @phone_number Phone number of the user @first_name First name of the user; 1-255 characters in length @last_name Last name of the user @user_id Identifier of the user, if known; otherwise 0
contact phone_number:string first_name:string last_name:string user_id:int32 = Contact;
//@description Describes a user contact @phone_number Phone number of the user @first_name First name of the user; 1-255 characters in length @last_name Last name of the user @vcard Additional data about the user in a form of vCard; 0-2048 bytes in length @user_id Identifier of the user, if known; otherwise 0
contact phone_number:string first_name:string last_name:string vcard:string user_id:int32 = Contact;
//@description Describes a location on planet Earth @latitude Latitude of the location in degrees; as defined by the sender @longitude Longitude of the location, in degrees; as defined by the sender
location latitude:double longitude:double = Location;
@ -2769,7 +2769,7 @@ unblockUser user_id:int32 = Ok;
getBlockedUsers offset:int32 limit:int32 = Users;
//@description Adds new contacts or edits existing contacts; contacts' user identifiers are ignored @contacts The list of contacts to import or edit
//@description Adds new contacts or edits existing contacts; contacts' user identifiers are ignored @contacts The list of contacts to import or edit, contact's vCard are ignored and are not imported
importContacts contacts:vector<contact> = ImportedContacts;
//@description Searches for the specified query in the first names, last names and usernames of the known user contacts @query Query to search for; can be empty to return all contacts @limit Maximum number of users to be returned
@ -2782,7 +2782,7 @@ removeContacts user_ids:vector<int32> = Ok;
getImportedContactCount = Count;
//@description Changes imported contacts using the list of current user contacts saved on the device. Imports newly added contacts and, if at least the file database is enabled, deletes recently deleted contacts.
//-Query result depends on the result of the previous query, so only one query is possible at the same time @contacts The new list of contacts
//-Query result depends on the result of the previous query, so only one query is possible at the same time @contacts The new list of contacts, contact's vCard are ignored and are not imported
changeImportedContacts contacts:vector<contact> = ImportedContacts;
//@description Clears all imported contacts, contacts list remains unchanged

Binary file not shown.

View File

@ -45,7 +45,7 @@ inputMediaEmpty#9664f57f = InputMedia;
inputMediaUploadedPhoto#1e287d04 flags:# file:InputFile stickers:flags.0?Vector<InputDocument> ttl_seconds:flags.1?int = InputMedia;
inputMediaPhoto#b3ba0635 flags:# id:InputPhoto ttl_seconds:flags.0?int = InputMedia;
inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia;
inputMediaContact#a6e45987 phone_number:string first_name:string last_name:string = InputMedia;
inputMediaContact#f8ab7dfb phone_number:string first_name:string last_name:string vcard:string = InputMedia;
inputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector<DocumentAttribute> stickers:flags.0?Vector<InputDocument> ttl_seconds:flags.1?int = InputMedia;
inputMediaDocument#23ab23d2 flags:# id:InputDocument ttl_seconds:flags.0?int = InputMedia;
inputMediaVenue#c13d1c11 geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string = InputMedia;
@ -70,6 +70,7 @@ inputFileLocation#14637196 volume_id:long local_id:int secret:long = InputFileLo
inputEncryptedFileLocation#f5235d55 id:long access_hash:long = InputFileLocation;
inputDocumentFileLocation#430f0724 id:long access_hash:long version:int = InputFileLocation;
inputSecureFileLocation#cbc7ee28 id:long access_hash:long = InputFileLocation;
inputTakeoutFileLocation#29be5899 = InputFileLocation;
inputAppEvent#770656a8 time:double type:string peer:long data:string = InputAppEvent;
@ -130,7 +131,7 @@ messageService#9e19a1f6 flags:# out:flags.1?true mentioned:flags.4?true media_un
messageMediaEmpty#3ded6320 = MessageMedia;
messageMediaPhoto#695150d7 flags:# photo:flags.0?Photo ttl_seconds:flags.2?int = MessageMedia;
messageMediaGeo#56e0d474 geo:GeoPoint = MessageMedia;
messageMediaContact#5e7d2f39 phone_number:string first_name:string last_name:string user_id:int = MessageMedia;
messageMediaContact#cbf24940 phone_number:string first_name:string last_name:string vcard:string user_id:int = MessageMedia;
messageMediaUnsupported#9f84f49e = MessageMedia;
messageMediaDocument#9cb070d7 flags:# document:flags.0?Document ttl_seconds:flags.2?int = MessageMedia;
messageMediaWebPage#a32dd600 webpage:WebPage = MessageMedia;
@ -162,7 +163,7 @@ messageActionBotAllowed#abe9affe domain:string = MessageAction;
messageActionSecureValuesSentMe#1b287353 values:Vector<SecureValue> credentials:SecureCredentialsEncrypted = MessageAction;
messageActionSecureValuesSent#d95c6154 types:Vector<SecureValueType> = MessageAction;
dialog#e4def5db flags:# pinned:flags.2?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#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;
photoEmpty#2331b22d id:long = Photo;
photo#9288dd29 flags:# has_stickers:flags.0?true id:long access_hash:long date:int sizes:Vector<PhotoSize> = Photo;
@ -172,7 +173,7 @@ photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = Phot
photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize;
geoPointEmpty#1117dd5f = GeoPoint;
geoPoint#2049d70c long:double lat:double = GeoPoint;
geoPoint#296f104 long:double lat:double access_hash:long = GeoPoint;
auth.checkedPhone#811ea28e phone_registered:Bool = auth.CheckedPhone;
@ -222,6 +223,7 @@ contacts.blockedSlice#900802a1 count:int blocked:Vector<ContactBlocked> users:Ve
messages.dialogs#15ba6c40 dialogs:Vector<Dialog> messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Dialogs;
messages.dialogsSlice#71e094f3 count:int dialogs:Vector<Dialog> messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Dialogs;
messages.dialogsNotModified#f0e3e596 count:int = messages.Dialogs;
messages.messages#8c718e87 messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.messagesSlice#b446ae3 count:int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
@ -318,6 +320,7 @@ updateFavedStickers#e511996d = Update;
updateChannelReadMessagesContents#89893b45 channel_id:int messages:Vector<int> = Update;
updateContactsReset#7084a7be = Update;
updateChannelAvailableMessages#70db6837 channel_id:int available_min_id:int = Update;
updateDialogUnreadMark#e16459c3 flags:# unread:flags.0?true peer:DialogPeer = Update;
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
@ -344,7 +347,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#eb7bb160 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 date:int expires:int test_mode:Bool this_dc:int dc_options:Vector<DcOption> 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 suggested_lang_code:flags.2?string lang_pack_version:flags.2?int = Config;
config#3213dbba 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 date:int expires:int test_mode:Bool this_dc:int dc_options:Vector<DcOption> 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 = Config;
nearestDc#8e1a1775 country:string this_dc:int nearest_dc:int = NearestDc;
@ -571,7 +574,7 @@ inputBotInlineMessageMediaAuto#3380c786 flags:# message:string entities:flags.1?
inputBotInlineMessageText#3dcd7a87 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineMessageMediaGeo#c1b15d65 flags:# geo_point:InputGeoPoint period:int reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineMessageMediaVenue#417bbf11 flags:# geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineMessageMediaContact#2daf01a7 flags:# phone_number:string first_name:string last_name:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineMessageMediaContact#a6edbffd flags:# phone_number:string first_name:string last_name:string vcard:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineMessageGame#4b425864 flags:# reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineResult#88bf9319 flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb:flags.4?InputWebDocument content:flags.5?InputWebDocument send_message:InputBotInlineMessage = InputBotInlineResult;
@ -583,7 +586,7 @@ botInlineMessageMediaAuto#764cf810 flags:# message:string entities:flags.1?Vecto
botInlineMessageText#8c7f65e2 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
botInlineMessageMediaGeo#b722de65 flags:# geo:GeoPoint period:int reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
botInlineMessageMediaVenue#8a86659c flags:# geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
botInlineMessageMediaContact#35edb4d4 flags:# phone_number:string first_name:string last_name:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
botInlineMessageMediaContact#18d1cdc2 flags:# phone_number:string first_name:string last_name:string vcard:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
botInlineResult#11965f3a flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb:flags.4?WebDocument content:flags.5?WebDocument send_message:BotInlineMessage = BotInlineResult;
botInlineMediaResult#17db940b flags:# id:string type:string photo:flags.0?Photo document:flags.1?Document title:flags.2?string description:flags.3?string send_message:BotInlineMessage = BotInlineResult;
@ -626,8 +629,9 @@ topPeerCategoryPeers#fb834291 category:TopPeerCategory count:int peers:Vector<To
contacts.topPeersNotModified#de266ef5 = contacts.TopPeers;
contacts.topPeers#70b772a8 categories:Vector<TopPeerCategoryPeers> chats:Vector<Chat> users:Vector<User> = contacts.TopPeers;
contacts.topPeersDisabled#b52c939d = contacts.TopPeers;
draftMessageEmpty#ba4baec5 = DraftMessage;
draftMessageEmpty#1b0c841a flags:# date:flags.0?int = DraftMessage;
draftMessage#fd8e711f flags:# no_webpage:flags.1?true reply_to_msg_id:flags.0?int message:string entities:flags.3?Vector<MessageEntity> date:int = DraftMessage;
messages.featuredStickersNotModified#4ede3cf = messages.FeaturedStickers;
@ -715,14 +719,13 @@ paymentRequestedInfo#909c3f94 flags:# name:flags.0?string phone:flags.1?string e
paymentSavedCredentialsCard#cdc27a1f id:string title:string = PaymentSavedCredentials;
webDocument#c61acbd8 url:string access_hash:long size:int mime_type:string attributes:Vector<DocumentAttribute> dc_id:int = WebDocument;
webDocument#1c570ed1 url:string access_hash:long size:int mime_type:string attributes:Vector<DocumentAttribute> = WebDocument;
webDocumentNoProxy#f9c8bcc6 url:string size:int mime_type:string attributes:Vector<DocumentAttribute> = WebDocument;
inputWebDocument#9bed434d url:string size:int mime_type:string attributes:Vector<DocumentAttribute> = InputWebDocument;
inputWebFileLocation#c239d686 url:string access_hash:long = InputWebFileLocation;
inputWebFileGeoPointLocation#66275a62 geo_point:InputGeoPoint w:int h:int zoom:int scale:int = InputWebFileLocation;
inputWebFileGeoMessageLocation#553f32eb peer:InputPeer msg_id:int w:int h:int zoom:int scale:int = InputWebFileLocation;
inputWebFileGeoPointLocation#9f2221c9 geo_point:InputGeoPoint access_hash:long w:int h:int zoom:int scale:int = InputWebFileLocation;
upload.webFile#21e753bc size:int mime_type:string file_type:storage.FileType mtime:int bytes:bytes = upload.WebFile;
@ -892,6 +895,10 @@ account.sentEmailCode#811f854f email_pattern:string length:int = account.SentEma
help.deepLinkInfoEmpty#66afa166 = help.DeepLinkInfo;
help.deepLinkInfo#6a4ee832 flags:# update_app:flags.0?true message:string entities:flags.1?Vector<MessageEntity> = help.DeepLinkInfo;
savedPhoneContact#1142bd56 phone:string first_name:string last_name:string date:int = SavedContact;
account.takeout#4dba4501 id:long = account.Takeout;
---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@ -899,6 +906,8 @@ invokeAfterMsgs#3dc4b4f0 {X:Type} msg_ids:Vector<long> query:!X = X;
initConnection#785188b8 {X:Type} flags:# api_id:int device_model:string system_version:string app_version:string system_lang_code:string lang_pack:string lang_code:string proxy:flags.0?InputClientProxy query:!X = X;
invokeWithLayer#da9b0d0d {X:Type} layer:int query:!X = X;
invokeWithoutUpdates#bf9459b7 {X:Type} query:!X = X;
invokeWithMessagesRange#365275f2 {X:Type} range:MessageRange query:!X = X;
invokeWithTakeout#aca9fd2e {X:Type} takeout_id:long query:!X = X;
auth.sendCode#86aef0ec flags:# allow_flashcall:flags.0?true phone_number:string current_number:flags.0?Bool api_id:int api_hash:string = auth.SentCode;
auth.signUp#1b067634 phone_number:string phone_code_hash:string phone_code:string first_name:string last_name:string = auth.Authorization;
@ -956,6 +965,8 @@ account.sendVerifyPhoneCode#823380b4 flags:# allow_flashcall:flags.0?true phone_
account.verifyPhone#4dd3a7f6 phone_number:string phone_code_hash:string phone_code:string = Bool;
account.sendVerifyEmailCode#7011509f email:string = account.SentEmailCode;
account.verifyEmail#ecba39db email:string code:string = Bool;
account.initTakeoutSession#f05b4804 flags:# contacts:flags.0?true message_users:flags.1?true message_chats:flags.2?true message_megagroups:flags.3?true message_channels:flags.4?true files:flags.5?true file_max_size:flags.5?int = account.Takeout;
account.finishTakeoutSession#1d2652ee flags:# success:flags.0?true = Bool;
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
users.getFullUser#ca30a5b1 id:InputUser = UserFull;
@ -976,9 +987,11 @@ contacts.resolveUsername#f93ccba3 username:string = contacts.ResolvedPeer;
contacts.getTopPeers#d4982db5 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true groups:flags.10?true channels:flags.15?true offset:int limit:int hash:int = contacts.TopPeers;
contacts.resetTopPeerRating#1ae373ac category:TopPeerCategory peer:InputPeer = Bool;
contacts.resetSaved#879537f1 = Bool;
contacts.getSaved#82f1e39f = Vector<SavedContact>;
contacts.toggleTopPeers#8514bdda enabled:Bool = Bool;
messages.getMessages#63c66506 id:Vector<InputMessage> = messages.Messages;
messages.getDialogs#191ba9c5 flags:# exclude_pinned:flags.0?true offset_date:int offset_id:int offset_peer:InputPeer limit:int = messages.Dialogs;
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.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;
@ -1073,6 +1086,9 @@ messages.getRecentLocations#bbc45b09 peer:InputPeer limit:int hash:int = message
messages.sendMultiMedia#2095512f flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true peer:InputPeer reply_to_msg_id:flags.0?int multi_media:Vector<InputSingleMedia> = Updates;
messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile;
messages.searchStickerSets#c2b7d08b flags:# exclude_featured:flags.0?true q:string hash:int = messages.FoundStickerSets;
messages.getSplitRanges#1cff7e08 = Vector<MessageRange>;
messages.markDialogUnread#c286d98f flags:# unread:flags.0?true peer:InputDialogPeer = Bool;
messages.getDialogUnreadMarks#22e24e22 = Vector<DialogPeer>;
updates.getState#edd4882a = updates.State;
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
@ -1139,6 +1155,7 @@ channels.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet =
channels.readMessageContents#eab5dc38 channel:InputChannel id:Vector<int> = Bool;
channels.deleteHistory#af369d42 channel:InputChannel max_id:int = Bool;
channels.togglePreHistoryHidden#eabbb94c channel:InputChannel enabled:Bool = Updates;
channels.getLeftChannels#8341ecc0 offset:int = messages.Chats;
bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON;
bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool;

Binary file not shown.

View File

@ -286,7 +286,7 @@ Result<uint64> Transport::read_auth_key_id(Slice message) {
}
Result<Transport::ReadResult> Transport::read(MutableSlice message, const AuthKey &auth_key, PacketInfo *info) {
if (message.size() < 16) {
if (message.size() < 12) {
if (message.size() < 4) {
return Status::Error(PSLICE() << "Invalid mtproto message: smaller than 4 bytes [size=" << message.size() << "]");
}
@ -294,14 +294,11 @@ Result<Transport::ReadResult> Transport::read(MutableSlice message, const AuthKe
auto code = as<int32>(message.begin());
if (code == 0) {
return ReadResult::make_nop();
} else if (code == -1) {
if (message.size() >= 8) {
return ReadResult::make_quick_ack(as<uint32>(message.begin() + 4));
}
} else if (code == -1 && message.size() >= 8) {
return ReadResult::make_quick_ack(as<uint32>(message.begin() + 4));
} else {
return ReadResult::make_error(code);
}
return Status::Error(PSLICE() << "Invalid small mtproto message");
}
info->auth_key_id = as<int64>(message.begin());

View File

@ -789,6 +789,8 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
shared_config.set_option_integer("call_packet_timeout_ms", config->call_packet_timeout_ms_);
shared_config.set_option_integer("call_receive_timeout_ms", config->call_receive_timeout_ms_);
shared_config.set_option_integer("webfile_dc_id", config->webfile_dc_id_);
// delete outdated options
shared_config.set_option_empty("chat_big_size");
shared_config.set_option_empty("group_size_max");

View File

@ -16,10 +16,11 @@
namespace td {
Contact::Contact(string phone_number, string first_name, string last_name, int32 user_id)
Contact::Contact(string phone_number, string first_name, string last_name, string vcard, int32 user_id)
: phone_number_(std::move(phone_number))
, first_name_(std::move(first_name))
, last_name_(std::move(last_name))
, vcard_(std::move(vcard))
, user_id_(user_id) {
if (!user_id_.is_valid()) {
user_id_ = UserId();
@ -39,11 +40,11 @@ string Contact::get_phone_number() const {
}
tl_object_ptr<td_api::contact> Contact::get_contact_object() const {
return make_tl_object<td_api::contact>(phone_number_, first_name_, last_name_, user_id_.get());
return make_tl_object<td_api::contact>(phone_number_, first_name_, last_name_, vcard_, user_id_.get());
}
tl_object_ptr<telegram_api::inputMediaContact> Contact::get_input_media_contact() const {
return make_tl_object<telegram_api::inputMediaContact>(phone_number_, first_name_, last_name_);
return make_tl_object<telegram_api::inputMediaContact>(phone_number_, first_name_, last_name_, vcard_);
}
SecretInputMedia Contact::get_secret_input_media_contact() const {
@ -58,12 +59,12 @@ tl_object_ptr<telegram_api::inputPhoneContact> Contact::get_input_phone_contact(
tl_object_ptr<telegram_api::inputBotInlineMessageMediaContact> Contact::get_input_bot_inline_message_media_contact(
int32 flags, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const {
return make_tl_object<telegram_api::inputBotInlineMessageMediaContact>(flags, phone_number_, first_name_, last_name_,
std::move(reply_markup));
vcard_, std::move(reply_markup));
}
bool operator==(const Contact &lhs, const Contact &rhs) {
return std::tie(lhs.phone_number_, lhs.first_name_, lhs.last_name_, lhs.user_id_) ==
std::tie(rhs.phone_number_, rhs.first_name_, rhs.last_name_, rhs.user_id_);
return std::tie(lhs.phone_number_, lhs.first_name_, lhs.last_name_, lhs.vcard_, lhs.user_id_) ==
std::tie(rhs.phone_number_, rhs.first_name_, rhs.last_name_, rhs.vcard_, rhs.user_id_);
}
bool operator!=(const Contact &lhs, const Contact &rhs) {
@ -72,8 +73,8 @@ bool operator!=(const Contact &lhs, const Contact &rhs) {
StringBuilder &operator<<(StringBuilder &string_builder, const Contact &contact) {
return string_builder << "Contact[phone_number = " << contact.phone_number_
<< ", first_name = " << contact.first_name_ << ", last_name = " << contact.last_name_ << ", "
<< contact.user_id_ << "]";
<< ", first_name = " << contact.first_name_ << ", last_name = " << contact.last_name_
<< ", vCard size = " << contact.vcard_.size() << contact.user_id_ << "]";
}
} // namespace td

View File

@ -25,6 +25,7 @@ class Contact {
string phone_number_;
string first_name_;
string last_name_;
string vcard_;
UserId user_id_;
friend bool operator==(const Contact &lhs, const Contact &rhs);
@ -38,7 +39,7 @@ class Contact {
public:
Contact() = default;
Contact(string phone_number, string first_name, string last_name, int32 user_id);
Contact(string phone_number, string first_name, string last_name, string vcard, int32 user_id);
void set_user_id(UserId user_id);
@ -54,26 +55,65 @@ class Contact {
tl_object_ptr<telegram_api::inputPhoneContact> get_input_phone_contact(int64 client_id) const;
// TODO very strange function
tl_object_ptr<telegram_api::inputBotInlineMessageMediaContact> get_input_bot_inline_message_media_contact(
int32 flags, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const;
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
bool has_first_name = !first_name_.empty();
bool has_last_name = !last_name_.empty();
bool has_vcard = !vcard_.empty();
bool has_user_id = user_id_.is_valid();
BEGIN_STORE_FLAGS();
STORE_FLAG(has_first_name);
STORE_FLAG(has_last_name);
STORE_FLAG(has_vcard);
STORE_FLAG(has_user_id);
END_STORE_FLAGS();
store(phone_number_, storer);
store(first_name_, storer);
store(last_name_, storer);
store(user_id_, storer);
if (has_first_name) {
store(first_name_, storer);
}
if (has_last_name) {
store(last_name_, storer);
}
if (has_vcard) {
store(vcard_, storer);
}
if (has_user_id) {
store(user_id_, storer);
}
}
template <class ParserT>
void parse(ParserT &parser) {
using td::parse;
bool has_first_name = true;
bool has_last_name = true;
bool has_vcard = false;
bool has_user_id = true;
if (parser.version() >= static_cast<int32>(Version::AddContactVcard)) {
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_first_name);
PARSE_FLAG(has_last_name);
PARSE_FLAG(has_vcard);
PARSE_FLAG(has_user_id);
END_PARSE_FLAGS();
}
parse(phone_number_, parser);
parse(first_name_, parser);
parse(last_name_, parser);
parse(user_id_, parser);
if (has_first_name) {
parse(first_name_, parser);
}
if (has_last_name) {
parse(last_name_, parser);
}
if (has_vcard) {
parse(vcard_, parser);
}
if (has_user_id) {
parse(user_id_, parser);
}
}
};

View File

@ -3469,7 +3469,7 @@ std::pair<vector<UserId>, vector<int32>> ContactsManager::import_contacts(
td_->create_handler<ImportContactsQuery>(std::move(promise))
->send(transform(contacts,
[](const tl_object_ptr<td_api::contact> &contact) {
return Contact(contact->phone_number_, contact->first_name_, contact->last_name_, 0);
return Contact(contact->phone_number_, contact->first_name_, contact->last_name_, string(), 0);
}),
random_id);
return {};
@ -3645,7 +3645,7 @@ std::pair<vector<UserId>, vector<int32>> ContactsManager::change_imported_contac
auto new_contacts = transform(std::move(contacts), [](tl_object_ptr<td_api::contact> &&contact) {
return Contact(std::move(contact->phone_number_), std::move(contact->first_name_), std::move(contact->last_name_),
0);
string(), 0);
});
vector<size_t> new_contacts_unique_id(new_contacts.size());

View File

@ -244,7 +244,6 @@ std::pair<DocumentsManager::DocumentType, FileId> DocumentsManager::on_get_docum
}
auto http_url = r_http_url.move_as_ok();
dc_id = web_document->dc_id_;
access_hash = web_document->access_hash_;
url = http_url.get_url();
file_name = get_url_query_file_name(http_url.query_);
@ -273,7 +272,7 @@ std::pair<DocumentsManager::DocumentType, FileId> DocumentsManager::on_get_docum
}
LOG(DEBUG) << "Receive document with id = " << id << " of type " << static_cast<int32>(document_type);
if (!is_web_no_proxy && !DcId::is_valid(dc_id)) {
if (!is_web && !DcId::is_valid(dc_id)) {
LOG(ERROR) << "Wrong dc_id = " << dc_id;
return {DocumentType::Unknown, FileId()};
}
@ -297,9 +296,8 @@ std::pair<DocumentsManager::DocumentType, FileId> DocumentsManager::on_get_docum
td_->file_manager_->set_encryption_key(file_id, std::move(encryption_key));
}
} else if (!is_web_no_proxy) {
file_id =
td_->file_manager_->register_remote(FullRemoteFileLocation(file_type, url, access_hash, DcId::internal(dc_id)),
FileLocationSource::FromServer, owner_dialog_id, 0, size, file_name);
file_id = td_->file_manager_->register_remote(FullRemoteFileLocation(file_type, url, access_hash),
FileLocationSource::FromServer, owner_dialog_id, 0, size, file_name);
} else {
auto r_file_id = td_->file_manager_->from_persistent_id(url, file_type);
if (r_file_id.is_error()) {

View File

@ -96,9 +96,25 @@ void Global::update_server_time_difference(double diff) {
}
}
DcId Global::get_webfile_dc_id() const {
int32 dc_id = shared_config_->get_option_integer("webfile_dc_id");
if (!DcId::is_valid(dc_id)) {
if (is_test_dc()) {
dc_id = 2;
} else {
dc_id = 4;
}
CHECK(DcId::is_valid(dc_id));
}
return DcId::internal(dc_id);
}
void Global::set_net_query_dispatcher(std::unique_ptr<NetQueryDispatcher> net_query_dispatcher) {
net_query_dispatcher_ = std::move(net_query_dispatcher);
}
void Global::set_shared_config(std::unique_ptr<ConfigShared> shared_config) {
shared_config_ = std::move(shared_config);
}

View File

@ -7,6 +7,7 @@
#pragma once
#include "td/telegram/DhConfig.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/NetQueryCreator.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/TdParameters.h"
@ -250,6 +251,8 @@ class Global : public ActorContext {
return slow_net_scheduler_id_;
}
DcId get_webfile_dc_id() const;
#if !TD_HAVE_ATOMIC_SHARED_PTR
std::mutex dh_config_mutex_;
#endif

View File

@ -377,9 +377,9 @@ bool InlineQueriesManager::register_inline_message_content(
}
case telegram_api::botInlineMessageMediaContact::ID: {
auto inline_message_contact = move_tl_object_as<telegram_api::botInlineMessageMediaContact>(inline_message);
message_content = make_unique<MessageContact>(Contact(inline_message_contact->phone_number_,
inline_message_contact->first_name_,
inline_message_contact->last_name_, 0));
message_content = make_unique<MessageContact>(
Contact(std::move(inline_message_contact->phone_number_), std::move(inline_message_contact->first_name_),
std::move(inline_message_contact->last_name_), std::move(inline_message_contact->vcard_), 0));
reply_markup = std::move(inline_message_contact->reply_markup_);
break;
}
@ -1065,7 +1065,7 @@ tl_object_ptr<td_api::voiceNote> copy(const td_api::voiceNote &obj) {
template <>
tl_object_ptr<td_api::contact> copy(const td_api::contact &obj) {
return make_tl_object<td_api::contact>(obj.phone_number_, obj.first_name_, obj.last_name_, obj.user_id_);
return make_tl_object<td_api::contact>(obj.phone_number_, obj.first_name_, obj.last_name_, obj.vcard_, obj.user_id_);
}
template <>
@ -1453,10 +1453,10 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
auto inline_message_contact =
static_cast<const telegram_api::botInlineMessageMediaContact *>(result->send_message_.get());
Contact c(inline_message_contact->phone_number_, inline_message_contact->first_name_,
inline_message_contact->last_name_, 0);
inline_message_contact->last_name_, inline_message_contact->vcard_, 0);
contact->contact_ = c.get_contact_object();
} else {
Contact c(std::move(result->description_), std::move(result->title_), string(), 0);
Contact c(std::move(result->description_), std::move(result->title_), string(), string(), 0);
contact->contact_ = c.get_contact_object();
}
contact->thumbnail_ = register_thumbnail(std::move(result->thumb_));
@ -1477,7 +1477,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
location->location_ = l.get_location_object();
} else {
auto coordinates = split(Slice(result->description_));
Location l(to_double(coordinates.first), to_double(coordinates.second));
Location l(to_double(coordinates.first), to_double(coordinates.second), 0);
location->location_ = l.get_location_object();
}
location->thumbnail_ = register_thumbnail(std::move(result->thumb_));

View File

@ -17,20 +17,21 @@
namespace td {
void Location::init(double latitude, double longitude) {
void Location::init(double latitude, double longitude, int64 access_hash) {
if (std::isfinite(latitude) && std::isfinite(longitude) && std::abs(latitude) <= 90 && std::abs(longitude) <= 180) {
is_empty_ = false;
latitude_ = latitude;
longitude_ = longitude;
access_hash_ = access_hash;
}
}
Location::Location(double latitude, double longitude) {
init(latitude, longitude);
Location::Location(double latitude, double longitude, int64 access_hash) {
init(latitude, longitude, access_hash);
}
Location::Location(const tl_object_ptr<secret_api::decryptedMessageMediaGeoPoint> &geo_point)
: Location(geo_point->lat_, geo_point->long_) {
: Location(geo_point->lat_, geo_point->long_, 0) {
}
Location::Location(const tl_object_ptr<telegram_api::GeoPoint> &geo_point_ptr) {
@ -42,7 +43,7 @@ Location::Location(const tl_object_ptr<telegram_api::GeoPoint> &geo_point_ptr) {
break;
case telegram_api::geoPoint::ID: {
auto geo_point = static_cast<const telegram_api::geoPoint *>(geo_point_ptr.get());
init(geo_point->lat_, geo_point->long_);
init(geo_point->lat_, geo_point->long_, geo_point->access_hash_);
break;
}
default:
@ -56,7 +57,7 @@ Location::Location(const tl_object_ptr<td_api::location> &location) {
return;
}
init(location->latitude_, location->longitude_);
init(location->latitude_, location->longitude_, 0);
}
bool Location::empty() const {
@ -139,6 +140,10 @@ bool Venue::empty() const {
return location_.empty();
}
const Location &Venue::location() const {
return location_;
}
tl_object_ptr<td_api::venue> Venue::get_venue_object() const {
return make_tl_object<td_api::venue>(location_.get_location_object(), title_, address_, provider_, id_, type_);
}

View File

@ -23,18 +23,19 @@ class Location {
bool is_empty_ = true;
double latitude_ = 0.0;
double longitude_ = 0.0;
int64 access_hash_ = 0;
friend bool operator==(const Location &lhs, const Location &rhs);
friend bool operator!=(const Location &lhs, const Location &rhs);
friend StringBuilder &operator<<(StringBuilder &string_builder, const Location &location);
void init(double latitude, double longitude);
void init(double latitude, double longitude, int64 access_hash);
public:
Location() = default;
Location(double latitude, double longitude);
Location(double latitude, double longitude, int64 access_hash);
explicit Location(const tl_object_ptr<secret_api::decryptedMessageMediaGeoPoint> &geo_point);
@ -53,29 +54,49 @@ class Location {
double get_latitude() const {
return latitude_;
}
double get_longitude() const {
return longitude_;
}
int64 get_access_hash() const {
return access_hash_;
}
void set_access_hash(int64 access_hash) {
access_hash_ = access_hash;
}
SecretInputMedia get_secret_input_media_geo_point() const;
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
bool has_access_hash = access_hash_ != 0;
BEGIN_STORE_FLAGS();
STORE_FLAG(is_empty_);
STORE_FLAG(has_access_hash);
END_STORE_FLAGS();
store(latitude_, storer);
store(longitude_, storer);
if (has_access_hash) {
store(access_hash_, storer);
}
}
template <class ParserT>
void parse(ParserT &parser) {
using td::parse;
bool has_access_hash;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_empty_);
PARSE_FLAG(has_access_hash);
END_PARSE_FLAGS();
parse(latitude_, parser);
parse(longitude_, parser);
if (has_access_hash) {
parse(access_hash_, parser);
}
}
};
@ -109,6 +130,12 @@ class Venue {
bool empty() const;
const Location &location() const;
void set_access_hash(int64 access_hash) {
location_.set_access_hash(access_hash);
}
tl_object_ptr<td_api::venue> get_venue_object() const;
tl_object_ptr<telegram_api::inputMediaVenue> get_input_media_venue() const;

View File

@ -5,7 +5,6 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/telegram/MessagesManager.h"
#include "td/telegram/secret_api.hpp"
#include "td/telegram/td_api.hpp"
#include "td/telegram/telegram_api.h"
@ -491,7 +490,7 @@ class GetDialogListQuery : public NetActorOnce {
int32 flags = telegram_api::messages_getDialogs::EXCLUDE_PINNED_MASK;
auto query = G()->net_query_creator().create(create_storer(telegram_api::messages_getDialogs(
flags, false /*ignored*/, offset_date, offset_message_id.get(), std::move(input_peer), limit)));
flags, false /*ignored*/, offset_date, offset_message_id.get(), std::move(input_peer), limit, 0)));
send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback,
std::move(query), actor_shared(this), sequence_id);
}
@ -504,22 +503,29 @@ class GetDialogListQuery : public NetActorOnce {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetDialogListQuery " << to_string(ptr);
int32 constructor_id = ptr->get_id();
auto promise = PromiseCreator::lambda(
[promise = std::move(promise_)](Result<> result) mutable { promise.set_result(std::move(result)); });
if (constructor_id == telegram_api::messages_dialogs::ID) {
auto dialogs = move_tl_object_as<telegram_api::messages_dialogs>(ptr);
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_));
td->contacts_manager_->on_get_users(std::move(dialogs->users_));
td->messages_manager_->on_get_dialogs(std::move(dialogs->dialogs_), narrow_cast<int32>(dialogs->dialogs_.size()),
std::move(dialogs->messages_), std::move(promise));
} else {
CHECK(constructor_id == telegram_api::messages_dialogsSlice::ID);
auto dialogs = move_tl_object_as<telegram_api::messages_dialogsSlice>(ptr);
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_));
td->contacts_manager_->on_get_users(std::move(dialogs->users_));
td->messages_manager_->on_get_dialogs(std::move(dialogs->dialogs_), max(dialogs->count_, 0),
std::move(dialogs->messages_), std::move(promise));
switch (ptr->get_id()) {
case telegram_api::messages_dialogs::ID: {
auto dialogs = move_tl_object_as<telegram_api::messages_dialogs>(ptr);
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_));
td->contacts_manager_->on_get_users(std::move(dialogs->users_));
td->messages_manager_->on_get_dialogs(std::move(dialogs->dialogs_),
narrow_cast<int32>(dialogs->dialogs_.size()),
std::move(dialogs->messages_), std::move(promise_));
break;
}
case telegram_api::messages_dialogsSlice::ID: {
auto dialogs = move_tl_object_as<telegram_api::messages_dialogsSlice>(ptr);
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_));
td->contacts_manager_->on_get_users(std::move(dialogs->users_));
td->messages_manager_->on_get_dialogs(std::move(dialogs->dialogs_), max(dialogs->count_, 0),
std::move(dialogs->messages_), std::move(promise_));
break;
}
case telegram_api::messages_dialogsNotModified::ID:
LOG(ERROR) << "Receive " << to_string(ptr);
return on_error(id, Status::Error(500, "Receive wrong server response messages.dialogsNotModified"));
default:
UNREACHABLE();
}
}
@ -914,7 +920,7 @@ class ToggleDialogPinQuery : public Td::ResultHandler {
if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ToggleDialogPinQuery")) {
LOG(ERROR) << "Receive error for ToggleDialogPinQuery: " << status;
}
td->messages_manager_->on_update_dialog_pinned(dialog_id_, !is_pinned_);
td->messages_manager_->on_update_dialog_is_pinned(dialog_id_, !is_pinned_);
promise_.set_error(std::move(status));
}
};
@ -15166,8 +15172,11 @@ Result<Contact> MessagesManager::process_input_message_contact(
if (!clean_input_string(contact->last_name_)) {
return Status::Error(400, "Last name must be encoded in UTF-8");
}
if (!clean_input_string(contact->vcard_)) {
return Status::Error(400, "vCard must be encoded in UTF-8");
}
return Contact(contact->phone_number_, contact->first_name_, contact->last_name_, contact->user_id_);
return Contact(contact->phone_number_, contact->first_name_, contact->last_name_, contact->vcard_, contact->user_id_);
}
Result<Game> MessagesManager::process_input_message_game(
@ -20128,11 +20137,12 @@ bool MessagesManager::update_dialog_draft_message(Dialog *d, unique_ptr<DraftMes
return false;
}
void MessagesManager::on_update_dialog_pinned(DialogId dialog_id, bool is_pinned) {
void MessagesManager::on_update_dialog_is_pinned(DialogId dialog_id, bool is_pinned) {
if (!dialog_id.is_valid()) {
LOG(ERROR) << "Receive pinn of invalid " << dialog_id;
LOG(ERROR) << "Receive pin of invalid " << dialog_id;
return;
}
auto d = get_dialog_force(dialog_id);
if (d == nullptr) {
LOG(WARNING) << "Can't apply updateDialogPinned with " << dialog_id;
@ -20145,7 +20155,7 @@ void MessagesManager::on_update_dialog_pinned(DialogId dialog_id, bool is_pinned
return;
}
set_dialog_is_pinned(d, is_pinned);
update_dialog_pos(d, false, "on_update_dialog_pinned");
update_dialog_pos(d, false, "on_update_dialog_is_pinned");
}
void MessagesManager::on_update_pinned_dialogs() {
@ -20154,6 +20164,27 @@ void MessagesManager::on_update_pinned_dialogs() {
get_sequence_dispatcher_id(DialogId(), -1));
}
void MessagesManager::on_update_dialog_is_marked_as_unread(DialogId dialog_id, bool is_marked_as_unread) {
if (!dialog_id.is_valid()) {
LOG(ERROR) << "Receive marking as unread of invalid " << dialog_id;
return;
}
auto d = get_dialog_force(dialog_id);
if (d == nullptr) {
// nothing to do
return;
}
/*
FIXME
if (is_marked_as_unread == d->is_marked_as_unread) {
return;
}
set_dialog_is_marked_as_unread(d, is_marked_as_unread);
*/
}
void MessagesManager::on_create_new_dialog_success(int64 random_id, tl_object_ptr<telegram_api::Updates> &&updates,
DialogType expected_type, Promise<Unit> &&promise) {
auto sent_messages = td_->updates_manager_->get_new_messages(updates.get());
@ -21974,7 +22005,7 @@ unique_ptr<MessageContent> MessagesManager::get_secret_message_content(
message_venue->venue_id_.clear();
}
auto m = make_unique<MessageVenue>(Venue(Location(message_venue->lat_, message_venue->long_),
auto m = make_unique<MessageVenue>(Venue(Location(message_venue->lat_, message_venue->long_, 0),
std::move(message_venue->title_), std::move(message_venue->address_),
std::move(message_venue->provider_), std::move(message_venue->venue_id_),
string()));
@ -21996,8 +22027,9 @@ unique_ptr<MessageContent> MessagesManager::get_secret_message_content(
if (!clean_input_string(message_contact->last_name_)) {
message_contact->last_name_.clear();
}
return make_unique<MessageContact>(Contact(message_contact->phone_number_, message_contact->first_name_,
message_contact->last_name_, message_contact->user_id_));
return make_unique<MessageContact>(
Contact(std::move(message_contact->phone_number_), std::move(message_contact->first_name_),
std::move(message_contact->last_name_), string(), message_contact->user_id_));
}
case secret_api::decryptedMessageMediaWebPage::ID: {
auto media_web_page = move_tl_object_as<secret_api::decryptedMessageMediaWebPage>(media);
@ -22154,8 +22186,9 @@ unique_ptr<MessageContent> MessagesManager::get_message_content(FormattedText me
td_->contacts_manager_->get_user_id_object(UserId(message_contact->user_id_),
"messageMediaContact"); // to ensure updateUser
}
return make_unique<MessageContact>(Contact(message_contact->phone_number_, message_contact->first_name_,
message_contact->last_name_, message_contact->user_id_));
return make_unique<MessageContact>(Contact(
std::move(message_contact->phone_number_), std::move(message_contact->first_name_),
std::move(message_contact->last_name_), std::move(message_contact->vcard_), message_contact->user_id_));
}
case telegram_api::messageMediaDocument::ID: {
auto message_document = move_tl_object_as<telegram_api::messageMediaDocument>(media);
@ -23706,6 +23739,13 @@ bool MessagesManager::need_message_text_changed_warning(const Message *old_messa
return true;
}
int64 MessagesManager::choose_location_access_hash(const Location &first, const Location &second) {
if (second.get_access_hash() != 0) {
return second.get_access_hash();
}
return first.get_access_hash();
}
bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_message,
unique_ptr<MessageContent> new_content,
bool need_send_update_message_content, bool need_merge_files) {
@ -23717,6 +23757,7 @@ bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_me
const bool can_delete_old_document = old_message->message_id.is_yet_unsent() && false;
auto old_file_id = get_message_content_file_id(old_content.get());
int64 location_access_hash = 0;
bool need_finish_upload = old_file_id.is_valid() && need_merge_files;
if (old_content_type != new_content_type) {
need_update = true;
@ -23873,6 +23914,10 @@ bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_me
if (old_->period != new_->period) {
need_update = true;
}
if (old_->location.get_access_hash() != new_->location.get_access_hash()) {
is_content_changed = true;
location_access_hash = choose_location_access_hash(old_->location, new_->location);
}
break;
}
case MessageLocation::ID: {
@ -23881,6 +23926,10 @@ bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_me
if (old_->location != new_->location) {
need_update = true;
}
if (old_->location.get_access_hash() != new_->location.get_access_hash()) {
is_content_changed = true;
location_access_hash = choose_location_access_hash(old_->location, new_->location);
}
break;
}
case MessagePhoto::ID: {
@ -23950,6 +23999,10 @@ bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_me
if (old_->venue != new_->venue) {
need_update = true;
}
if (old_->venue.location().get_access_hash() != new_->venue.location().get_access_hash()) {
is_content_changed = true;
location_access_hash = choose_location_access_hash(old_->venue.location(), new_->venue.location());
}
break;
}
case MessageVideo::ID: {
@ -24177,6 +24230,21 @@ bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_me
} else {
update_message_content_file_id_remote(old_content.get(), get_message_content_file_id(new_content.get()));
}
if (location_access_hash != 0) {
switch (old_content->get_id()) {
case MessageLiveLocation::ID:
static_cast<MessageLiveLocation *>(old_content.get())->location.set_access_hash(location_access_hash);
break;
case MessageLocation::ID:
static_cast<MessageLocation *>(old_content.get())->location.set_access_hash(location_access_hash);
break;
case MessageVenue::ID:
static_cast<MessageVenue *>(old_content.get())->venue.set_access_hash(location_access_hash);
break;
default:
UNREACHABLE();
}
}
if (is_content_changed && !need_update) {
LOG(INFO) << "Content of " << old_message->message_id << " in " << dialog_id << " has changed";
}

View File

@ -997,10 +997,12 @@ class MessagesManager : public Actor {
void on_update_dialog_draft_message(DialogId dialog_id, tl_object_ptr<telegram_api::DraftMessage> &&draft_message);
void on_update_dialog_pinned(DialogId dialog_id, bool is_pinned);
void on_update_dialog_is_pinned(DialogId dialog_id, bool is_pinned);
void on_update_pinned_dialogs();
void on_update_dialog_is_marked_as_unread(DialogId dialog_id, bool is_marked_as_unread);
void on_update_service_notification(tl_object_ptr<telegram_api::updateServiceNotification> &&update);
void on_update_contact_registered(tl_object_ptr<telegram_api::updateContactRegistered> &&update);
@ -2215,8 +2217,10 @@ class MessagesManager : public Actor {
void update_message(Dialog *d, unique_ptr<Message> &old_message, unique_ptr<Message> new_message,
bool need_send_update_message_content, bool *need_update_dialog_pos);
bool need_message_text_changed_warning(const Message *old_message, const MessageText *old_content,
const MessageText *new_content);
static bool need_message_text_changed_warning(const Message *old_message, const MessageText *old_content,
const MessageText *new_content);
static int64 choose_location_access_hash(const Location &first, const Location &second);
bool update_message_content(DialogId dialog_id, Message *old_message, unique_ptr<MessageContent> new_content,
bool need_send_update_message_content, bool need_merge_files);

View File

@ -306,11 +306,6 @@ PhotoSize get_web_document_photo_size(FileManager *file_manager, FileType file_t
switch (web_document_ptr->get_id()) {
case telegram_api::webDocument::ID: {
auto web_document = move_tl_object_as<telegram_api::webDocument>(web_document_ptr);
if (!DcId::is_valid(web_document->dc_id_)) {
LOG(ERROR) << "Wrong dc_id = " << web_document->dc_id_;
return {};
}
auto r_http_url = parse_url(web_document->url_);
if (r_http_url.is_error()) {
LOG(ERROR) << "Can't parse URL " << web_document->url_;
@ -318,11 +313,9 @@ PhotoSize get_web_document_photo_size(FileManager *file_manager, FileType file_t
}
auto http_url = r_http_url.move_as_ok();
auto url = http_url.get_url();
file_id = file_manager->register_remote(
FullRemoteFileLocation(file_type, url, web_document->access_hash_, DcId::internal(web_document->dc_id_)),
FileLocationSource::FromServer, owner_dialog_id, 0, web_document->size_,
get_url_query_file_name(http_url.query_));
file_id = file_manager->register_remote(FullRemoteFileLocation(file_type, url, web_document->access_hash_),
FileLocationSource::FromServer, owner_dialog_id, 0, web_document->size_,
get_url_query_file_name(http_url.query_));
size = web_document->size_;
attributes = std::move(web_document->attributes_);
break;

View File

@ -376,6 +376,10 @@ static td_api::object_ptr<td_api::datedFile> get_dated_file_object(FileManager *
auto file_id = dated_file.file_id;
CHECK(file_id.is_valid());
auto file_view = file_manager->get_file_view(file_id);
if (!file_view.has_remote_location() || file_view.remote_location().is_web()) {
LOG(ERROR) << "Have wrong file in get_dated_file_object";
return nullptr;
}
dated_file.file_id = file_manager->register_remote(
FullRemoteFileLocation(FileType::SecureRaw, file_view.remote_location().get_id(),
file_view.remote_location().get_access_hash(), file_view.remote_location().get_dc_id()),

View File

@ -4234,7 +4234,8 @@ bool Td::is_internal_config_option(Slice name) {
return name == "call_ring_timeout_ms" || name == "call_receive_timeout_ms" || name == "channels_read_media_period" ||
name == "edit_time_limit" || name == "revoke_pm_inbox" || name == "revoke_time_limit" ||
name == "revoke_pm_time_limit" || name == "rating_e_decay" || name == "saved_animations_limit" ||
name == "recent_stickers_limit" || name == "expect_blocking" || name == "my_phone_number" || name == "auth";
name == "recent_stickers_limit" || name == "expect_blocking" || name == "my_phone_number" ||
name == "webfile_dc_id" || name == "auth";
}
void Td::on_config_option_updated(const string &name) {

View File

@ -199,7 +199,7 @@ class Td final : public NetQueryCallback {
static td_api::object_ptr<td_api::Object> static_request(td_api::object_ptr<td_api::Function> function);
private:
static constexpr const char *TDLIB_VERSION = "1.2.4";
static constexpr const char *TDLIB_VERSION = "1.2.5";
static constexpr int64 ONLINE_ALARM_ID = 0;
static constexpr int32 ONLINE_TIMEOUT = 240;
static constexpr int64 PING_SERVER_ALARM_ID = -1;

View File

@ -323,6 +323,10 @@ void TopDialogManager::on_result(NetQueryPtr net_query) {
if (top_peers_parent->get_id() == telegram_api::contacts_topPeersNotModified::ID) {
return;
}
if (top_peers_parent->get_id() == telegram_api::contacts_topPeersDisabled::ID) {
// FIXME
return;
}
CHECK(top_peers_parent->get_id() == telegram_api::contacts_topPeers::ID);
auto top_peers = move_tl_object_as<telegram_api::contacts_topPeers>(std::move(top_peers_parent));

View File

@ -1676,7 +1676,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateDraftMessage> u
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateDialogPinned> update, bool /*force_apply*/) {
td_->messages_manager_->on_update_dialog_pinned(
td_->messages_manager_->on_update_dialog_is_pinned(
DialogId(update->peer_), (update->flags_ & telegram_api::updateDialogPinned::PINNED_MASK) != 0);
}
@ -1684,6 +1684,11 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updatePinnedDialogs>
td_->messages_manager_->on_update_pinned_dialogs(); // TODO use update->order_
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateDialogUnreadMark> update, bool /*force_apply*/) {
td_->messages_manager_->on_update_dialog_is_marked_as_unread(
DialogId(update->peer_), (update->flags_ & telegram_api::updateDialogUnreadMark::UNREAD_MASK) != 0);
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateDcOptions> update, bool /*force_apply*/) {
send_closure(G()->config_manager(), &ConfigManager::on_dc_options_update, DcOptions(update->dc_options_));
}

View File

@ -227,6 +227,7 @@ class UpdatesManager : public Actor {
void on_update(tl_object_ptr<telegram_api::updateDialogPinned> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updatePinnedDialogs> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateDialogUnreadMark> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateBotInlineQuery> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateBotInlineSend> update, bool /*force_apply*/);

View File

@ -25,6 +25,7 @@ enum class Version : int32 {
AddCaptionEntities,
AddVenueType,
AddTermsOfService,
AddContactVcard,
Next
};

View File

@ -1413,7 +1413,7 @@ class CliClient final : public Actor {
limit = 10000;
}
send_request(make_tl_object<td_api::searchContacts>("", limit));
} else if (op == "ImportContacts") {
} else if (op == "ImportContacts" || op == "cic") {
vector<string> contacts_str = full_split(args, ';');
vector<tl_object_ptr<td_api::contact>> contacts;
for (auto c : contacts_str) {
@ -1422,27 +1422,18 @@ class CliClient final : public Actor {
string last_name;
std::tie(phone_number, c) = split(c, ',');
std::tie(first_name, last_name) = split(c, ',');
contacts.push_back(make_tl_object<td_api::contact>(phone_number, first_name, last_name, 0));
contacts.push_back(make_tl_object<td_api::contact>(phone_number, first_name, last_name, string(), 0));
}
send_request(make_tl_object<td_api::importContacts>(std::move(contacts)));
if (op == "cic") {
send_request(make_tl_object<td_api::changeImportedContacts>(std::move(contacts)));
} else {
send_request(make_tl_object<td_api::importContacts>(std::move(contacts)));
}
} else if (op == "RemoveContacts") {
send_request(make_tl_object<td_api::removeContacts>(as_user_ids(args)));
} else if (op == "gicc") {
send_request(make_tl_object<td_api::getImportedContactCount>());
} else if (op == "cic") {
vector<string> contacts_str = full_split(args, ';');
vector<tl_object_ptr<td_api::contact>> contacts;
for (auto c : contacts_str) {
string phone_number;
string first_name;
string last_name;
std::tie(phone_number, c) = split(c, ',');
std::tie(first_name, last_name) = split(c, ',');
contacts.push_back(make_tl_object<td_api::contact>(phone_number, first_name, last_name, 0));
}
send_request(make_tl_object<td_api::changeImportedContacts>(std::move(contacts)));
} else if (op == "ClearImportedContacts") {
send_request(make_tl_object<td_api::clearImportedContacts>());
} else {
@ -2557,7 +2548,7 @@ class CliClient final : public Actor {
std::tie(last_name, user_id) = split(args);
send_message(chat_id, make_tl_object<td_api::inputMessageContact>(make_tl_object<td_api::contact>(
phone_number, first_name, last_name, as_user_id(user_id))));
phone_number, first_name, last_name, string(), as_user_id(user_id))));
} else if (op == "sf") {
string chat_id;
string from_chat_id;

View File

@ -226,6 +226,7 @@ Result<std::pair<NetQueryPtr, bool>> FileDownloader::start_part(Part part, int32
NetQueryPtr net_query;
if (!use_cdn_) {
DcId dc_id = remote_.is_web() ? G()->get_webfile_dc_id() : remote_.get_dc_id();
net_query = G()->net_query_creator().create(
UniqueId::next(UniqueId::Type::Default, static_cast<uint8>(QueryType::Default)),
remote_.is_web()
@ -233,7 +234,7 @@ Result<std::pair<NetQueryPtr, bool>> FileDownloader::start_part(Part part, int32
static_cast<int32>(part.offset), static_cast<int32>(size)))
: create_storer(telegram_api::upload_getFile(remote_.as_input_file_location(),
static_cast<int32>(part.offset), static_cast<int32>(size))),
remote_.get_dc_id(), is_small_ ? NetQuery::Type::DownloadSmall : NetQuery::Type::Download);
dc_id, is_small_ ? NetQuery::Type::DownloadSmall : NetQuery::Type::Download);
} else {
if (remote_.is_web()) {
return Status::Error("Can't download web file from CDN");
@ -378,6 +379,7 @@ Status FileDownloader::process_check_query(NetQueryPtr net_query) {
add_hash_info(file_hashes);
return Status::OK();
}
Result<FileLoader::CheckInfo> FileDownloader::check_loop(int64 checked_prefix_size, int64 ready_prefix_size,
bool is_ready) {
if (!need_check_) {
@ -443,6 +445,7 @@ Result<FileLoader::CheckInfo> FileDownloader::check_loop(int64 checked_prefix_si
info.checked_prefix_size = checked_prefix_size;
return std::move(info);
}
void FileDownloader::add_hash_info(const std::vector<telegram_api::object_ptr<telegram_api::fileHash>> &hashes) {
for (auto &hash : hashes) {
//LOG(ERROR) << "ADD HASH " << hash->offset_ << "->" << hash->limit_;

View File

@ -7,6 +7,7 @@
#include "td/telegram/files/FileLoadManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/net/DcId.h"
#include "td/utils/common.h"
#include "td/utils/filesystem.h"
@ -51,7 +52,8 @@ void FileLoadManager::download(QueryId id, const FullRemoteFileLocation &remote_
bool is_small = size < 20 * 1024;
node->loader_ = create_actor<FileDownloader>("Downloader", remote_location, local, size, std::move(name),
encryption_key, is_small, search_file, std::move(callback));
auto &resource_manager = get_download_resource_manager(is_small, remote_location.get_dc_id());
DcId dc_id = remote_location.is_web() ? G()->get_webfile_dc_id() : remote_location.get_dc_id();
auto &resource_manager = get_download_resource_manager(is_small, dc_id);
send_closure(resource_manager, &ResourceManager::register_worker,
ActorShared<FileLoaderActor>(node->loader_.get(), static_cast<uint64>(-1)), priority);
query_id_to_node_id_[id] = node_id;

View File

@ -603,6 +603,7 @@ class FullRemoteFileLocation {
}
DcId get_dc_id() const {
CHECK(!is_web());
return dc_id_;
}
int64 get_access_hash() const {
@ -722,10 +723,10 @@ class FullRemoteFileLocation {
: file_type_(file_type), dc_id_(dc_id), variant_(CommonRemoteFileLocation{id, access_hash}) {
CHECK(is_common());
}
FullRemoteFileLocation(FileType file_type, string url, int64 access_hash, DcId dc_id)
FullRemoteFileLocation(FileType file_type, string url, int64 access_hash)
: file_type_(file_type)
, web_location_flag_{true}
, dc_id_(dc_id)
, dc_id_()
, variant_(WebRemoteFileLocation{std::move(url), access_hash}) {
CHECK(is_web());
CHECK(!web().url_.empty());
@ -777,9 +778,12 @@ class FullRemoteFileLocation {
inline StringBuilder &operator<<(StringBuilder &string_builder,
const FullRemoteFileLocation &full_remote_file_location) {
string_builder << "[" << file_type_name[static_cast<int32>(full_remote_file_location.file_type_)] << ", "
<< full_remote_file_location.get_dc_id() << ", location = ";
string_builder << "[" << file_type_name[static_cast<int32>(full_remote_file_location.file_type_)];
if (!full_remote_file_location.is_web()) {
string_builder << ", " << full_remote_file_location.get_dc_id();
}
string_builder << ", location = ";
if (full_remote_file_location.is_web()) {
string_builder << full_remote_file_location.web();
} else if (full_remote_file_location.is_photo()) {

View File

@ -397,11 +397,15 @@ bool FileView::can_download_from_server() const {
if (remote_location().file_type_ == FileType::Encrypted && encryption_key().empty()) {
return false;
}
if (remote_location().is_web()) {
return true;
}
if (remote_location().get_dc_id().is_empty()) {
return false;
}
return true;
}
bool FileView::can_generate() const {
return has_generate_location();
}
@ -952,8 +956,8 @@ Result<FileId> FileManager::merge(FileId x_file_id, FileId y_file_id, bool no_sy
}
if (x_node->remote_.type() == RemoteFileLocation::Type::Full &&
y_node->remote_.type() == RemoteFileLocation::Type::Full &&
x_node->remote_.full().get_dc_id() != y_node->remote_.full().get_dc_id()) {
y_node->remote_.type() == RemoteFileLocation::Type::Full && !x_node->remote_.full().is_web() &&
!y_node->remote_.full().is_web() && x_node->remote_.full().get_dc_id() != y_node->remote_.full().get_dc_id()) {
LOG(ERROR) << "File remote location was changed from " << y_node->remote_.full() << " to "
<< x_node->remote_.full();
}

View File

@ -9,6 +9,8 @@
#include "td/utils/logging.h"
#include "td/utils/StringBuilder.h"
#include <tuple>
namespace td {
class DcId {
@ -66,7 +68,7 @@ class DcId {
return dc_id_ == other.dc_id_ && is_external_ == other.is_external_;
}
bool operator<(DcId other) const {
return dc_id_ < other.dc_id_;
return std::tie(dc_id_, is_external_) < std::tie(other.dc_id_, other.is_external_);
}
bool operator!=(DcId other) const {
return !(*this == other);

View File

@ -18,7 +18,7 @@ class HeaderStorer {
}
template <class StorerT>
void store(StorerT &storer) const {
constexpr int32 LAYER = 81;
constexpr int32 LAYER = 82;
using td::store;
// invokeWithLayer#da9b0d0d {X:Type} layer:int query:!X = X;

View File

@ -6,6 +6,7 @@
//
#pragma once
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/NetQuery.h"
#include "td/telegram/UniqueId.h"

View File

@ -5,6 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/telegram/net/NetQuery.h"
#include "td/actor/actor.h"

View File

@ -5,6 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/telegram/net/AuthDataShared.h"
#include "td/telegram/net/NetQuery.h"

View File

@ -23,6 +23,7 @@
#include <memory>
namespace td {
class PublicRsaKeyWatchdog : public NetActor {
public:
explicit PublicRsaKeyWatchdog(ActorShared<> parent);
@ -43,4 +44,5 @@ class PublicRsaKeyWatchdog : public NetActor {
void sync(BufferSlice cdn_config_serialized);
void sync_key(std::shared_ptr<PublicRsaKeyShared> &key);
};
} // namespace td

View File

@ -5,6 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/telegram/net/AuthDataShared.h"
#include "td/telegram/net/NetQuery.h"