Update layer to 98.
GitOrigin-RevId: 7bc09a6ec637f12b2f90bc1fb6d82903feffc376
This commit is contained in:
parent
0cdac3fd83
commit
4c781ebb7b
@ -1837,7 +1837,7 @@ chatEventDescriptionChanged old_description:string new_description:string = Chat
|
||||
chatEventUsernameChanged old_username:string new_username:string = ChatEventAction;
|
||||
|
||||
//@description The chat photo was changed @old_photo Previous chat photo value; may be null @new_photo New chat photo value; may be null
|
||||
chatEventPhotoChanged old_photo:chatPhoto new_photo:chatPhoto = ChatEventAction;
|
||||
chatEventPhotoChanged old_photo:photo new_photo:photo = ChatEventAction;
|
||||
|
||||
//@description The can_invite_users permission of a supergroup chat was toggled @can_invite_users New value of can_invite_users permission
|
||||
chatEventInvitesToggled can_invite_users:Bool = ChatEventAction;
|
||||
|
Binary file not shown.
@ -69,9 +69,12 @@ inputPhoto#3bb3b94a id:long access_hash:long file_reference:bytes = InputPhoto;
|
||||
|
||||
inputFileLocation#dfdaabe1 volume_id:long local_id:int secret:long file_reference:bytes = InputFileLocation;
|
||||
inputEncryptedFileLocation#f5235d55 id:long access_hash:long = InputFileLocation;
|
||||
inputDocumentFileLocation#196683d9 id:long access_hash:long file_reference:bytes = InputFileLocation;
|
||||
inputDocumentFileLocation#bad07584 id:long access_hash:long file_reference:bytes thumb_size:string = InputFileLocation;
|
||||
inputSecureFileLocation#cbc7ee28 id:long access_hash:long = InputFileLocation;
|
||||
inputTakeoutFileLocation#29be5899 = InputFileLocation;
|
||||
inputPhotoFileLocation#40181ffe id:long access_hash:long file_reference:bytes thumb_size:string = InputFileLocation;
|
||||
inputPeerPhotoFileLocation#27d69997 flags:# big:flags.0?true peer:InputPeer volume_id:long local_id:int = InputFileLocation;
|
||||
inputStickerSetThumb#dbaeae9 stickerset:InputStickerSet volume_id:long local_id:int = InputFileLocation;
|
||||
|
||||
peerUser#9db1bc6d user_id:int = Peer;
|
||||
peerChat#bad0e5bb chat_id:int = Peer;
|
||||
@ -88,14 +91,11 @@ storage.fileMov#4b09ebbc = storage.FileType;
|
||||
storage.fileMp4#b3cea0e4 = storage.FileType;
|
||||
storage.fileWebp#1081464c = storage.FileType;
|
||||
|
||||
fileLocationUnavailable#7c596b46 volume_id:long local_id:int secret:long = FileLocation;
|
||||
fileLocation#91d11eb dc_id:int volume_id:long local_id:int secret:long file_reference:bytes = FileLocation;
|
||||
|
||||
userEmpty#200250ba id:int = User;
|
||||
user#2e13f4c3 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?string bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User;
|
||||
|
||||
userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto;
|
||||
userProfilePhoto#d559d8c8 photo_id:long photo_small:FileLocation photo_big:FileLocation = UserProfilePhoto;
|
||||
userProfilePhoto#ecd75d8c photo_id:long photo_small:FileLocation photo_big:FileLocation dc_id:int = UserProfilePhoto;
|
||||
|
||||
userStatusEmpty#9d05049 = UserStatus;
|
||||
userStatusOnline#edb93949 expires:int = UserStatus;
|
||||
@ -121,7 +121,7 @@ chatParticipantsForbidden#fc900c2b flags:# chat_id:int self_participant:flags.0?
|
||||
chatParticipants#3f460fed chat_id:int participants:Vector<ChatParticipant> version:int = ChatParticipants;
|
||||
|
||||
chatPhotoEmpty#37c1011c = ChatPhoto;
|
||||
chatPhoto#6153276a photo_small:FileLocation photo_big:FileLocation = ChatPhoto;
|
||||
chatPhoto#475cdbd5 photo_small:FileLocation photo_big:FileLocation dc_id:int = ChatPhoto;
|
||||
|
||||
messageEmpty#83e5de54 id:int = Message;
|
||||
message#44f9b43d flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true id:int from_id:flags.8?int to_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?int reply_to_msg_id:flags.3?int date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector<MessageEntity> views:flags.10?int edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long = Message;
|
||||
@ -156,7 +156,7 @@ messageActionHistoryClear#9fbab604 = MessageAction;
|
||||
messageActionGameScore#92a72876 game_id:long score:int = MessageAction;
|
||||
messageActionPaymentSentMe#8f31b327 flags:# currency:string total_amount:long payload:bytes info:flags.0?PaymentRequestedInfo shipping_option_id:flags.1?string charge:PaymentCharge = MessageAction;
|
||||
messageActionPaymentSent#40699cd0 currency:string total_amount:long = MessageAction;
|
||||
messageActionPhoneCall#80e11a7f flags:# call_id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = MessageAction;
|
||||
messageActionPhoneCall#80e11a7f flags:# video:flags.2?true call_id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = MessageAction;
|
||||
messageActionScreenshotTaken#4792929b = MessageAction;
|
||||
messageActionCustomAction#fae69f56 message:string = MessageAction;
|
||||
messageActionBotAllowed#abe9affe domain:string = MessageAction;
|
||||
@ -167,7 +167,7 @@ messageActionContactSignUp#f3f25f76 = MessageAction;
|
||||
dialog#e4def5db flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage = Dialog;
|
||||
|
||||
photoEmpty#2331b22d id:long = Photo;
|
||||
photo#9c477dd8 flags:# has_stickers:flags.0?true id:long access_hash:long file_reference:bytes date:int sizes:Vector<PhotoSize> = Photo;
|
||||
photo#d07504a5 flags:# has_stickers:flags.0?true id:long access_hash:long file_reference:bytes date:int sizes:Vector<PhotoSize> dc_id:int = Photo;
|
||||
|
||||
photoSizeEmpty#e17e23c type:string = PhotoSize;
|
||||
photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize;
|
||||
@ -494,13 +494,13 @@ chatInviteEmpty#69df3769 = ExportedChatInvite;
|
||||
chatInviteExported#fc2e05bc link:string = ExportedChatInvite;
|
||||
|
||||
chatInviteAlready#5a686d7c chat:Chat = ChatInvite;
|
||||
chatInvite#db74f558 flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true title:string photo:ChatPhoto participants_count:int participants:flags.4?Vector<User> = ChatInvite;
|
||||
chatInvite#dfc2f58e flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true title:string photo:Photo participants_count:int participants:flags.4?Vector<User> = ChatInvite;
|
||||
|
||||
inputStickerSetEmpty#ffb62b95 = InputStickerSet;
|
||||
inputStickerSetID#9de7a269 id:long access_hash:long = InputStickerSet;
|
||||
inputStickerSetShortName#861cc8a0 short_name:string = InputStickerSet;
|
||||
|
||||
stickerSet#6a90bcb7 flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumb:flags.4?PhotoSize count:int hash:int = StickerSet;
|
||||
stickerSet#eeb46f27 flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumb:flags.4?PhotoSize thumb_dc_id:flags.4?int count:int hash:int = StickerSet;
|
||||
|
||||
messages.stickerSet#b60a24a6 set:StickerSet packs:Vector<StickerPack> documents:Vector<Document> = messages.StickerSet;
|
||||
|
||||
@ -778,11 +778,11 @@ inputStickerSetItem#ffa0a496 flags:# document:InputDocument emoji:string mask_co
|
||||
inputPhoneCall#1e36fded id:long access_hash:long = InputPhoneCall;
|
||||
|
||||
phoneCallEmpty#5366c915 id:long = PhoneCall;
|
||||
phoneCallWaiting#1b8f4ad1 flags:# id:long access_hash:long date:int admin_id:int participant_id:int protocol:PhoneCallProtocol receive_date:flags.0?int = PhoneCall;
|
||||
phoneCallRequested#83761ce4 id:long access_hash:long date:int admin_id:int participant_id:int g_a_hash:bytes protocol:PhoneCallProtocol = PhoneCall;
|
||||
phoneCallAccepted#6d003d3f id:long access_hash:long date:int admin_id:int participant_id:int g_b:bytes protocol:PhoneCallProtocol = PhoneCall;
|
||||
phoneCall#e6f9ddf3 flags:# p2p_allowed:flags.5?true id:long access_hash:long date:int admin_id:int participant_id:int g_a_or_b:bytes key_fingerprint:long protocol:PhoneCallProtocol connection:PhoneConnection alternative_connections:Vector<PhoneConnection> start_date:int = PhoneCall;
|
||||
phoneCallDiscarded#50ca4de1 flags:# need_rating:flags.2?true need_debug:flags.3?true id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = PhoneCall;
|
||||
phoneCallWaiting#1b8f4ad1 flags:# video:flags.5?true id:long access_hash:long date:int admin_id:int participant_id:int protocol:PhoneCallProtocol receive_date:flags.0?int = PhoneCall;
|
||||
phoneCallRequested#87eabb53 flags:# video:flags.5?true id:long access_hash:long date:int admin_id:int participant_id:int g_a_hash:bytes protocol:PhoneCallProtocol = PhoneCall;
|
||||
phoneCallAccepted#997c454a flags:# video:flags.5?true id:long access_hash:long date:int admin_id:int participant_id:int g_b:bytes protocol:PhoneCallProtocol = PhoneCall;
|
||||
phoneCall#8742ae7f flags:# p2p_allowed:flags.5?true id:long access_hash:long date:int admin_id:int participant_id:int g_a_or_b:bytes key_fingerprint:long protocol:PhoneCallProtocol connections:Vector<PhoneConnection> start_date:int = PhoneCall;
|
||||
phoneCallDiscarded#50ca4de1 flags:# need_rating:flags.2?true need_debug:flags.3?true video:flags.5?true id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = PhoneCall;
|
||||
|
||||
phoneConnection#9d4c17c0 id:long ip:string ipv6:string port:int peer_tag:bytes = PhoneConnection;
|
||||
|
||||
@ -808,7 +808,7 @@ langPackLanguage#eeca5ce3 flags:# official:flags.0?true rtl:flags.2?true beta:fl
|
||||
channelAdminLogEventActionChangeTitle#e6dfb825 prev_value:string new_value:string = ChannelAdminLogEventAction;
|
||||
channelAdminLogEventActionChangeAbout#55188a2e prev_value:string new_value:string = ChannelAdminLogEventAction;
|
||||
channelAdminLogEventActionChangeUsername#6a4afc38 prev_value:string new_value:string = ChannelAdminLogEventAction;
|
||||
channelAdminLogEventActionChangePhoto#b82f55c3 prev_photo:ChatPhoto new_photo:ChatPhoto = ChannelAdminLogEventAction;
|
||||
channelAdminLogEventActionChangePhoto#434bd2af prev_photo:Photo new_photo:Photo = ChannelAdminLogEventAction;
|
||||
channelAdminLogEventActionToggleInvites#1b7907ae new_value:Bool = ChannelAdminLogEventAction;
|
||||
channelAdminLogEventActionToggleSignatures#26ae0971 new_value:Bool = ChannelAdminLogEventAction;
|
||||
channelAdminLogEventActionUpdatePinned#e9e82c18 message:Message = ChannelAdminLogEventAction;
|
||||
@ -1013,6 +1013,8 @@ emojiURL#a575739d url:string = EmojiURL;
|
||||
|
||||
emojiLanguage#b3fb5361 lang_code:string = EmojiLanguage;
|
||||
|
||||
fileLocationToBeDeprecated#bc7fc6cd volume_id:long local_id:int = FileLocation;
|
||||
|
||||
---functions---
|
||||
|
||||
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
||||
@ -1312,11 +1314,11 @@ stickers.changeStickerPosition#ffb6d4ca sticker:InputDocument position:int = mes
|
||||
stickers.addStickerToSet#8653febe stickerset:InputStickerSet sticker:InputStickerSetItem = messages.StickerSet;
|
||||
|
||||
phone.getCallConfig#55451fa9 = DataJSON;
|
||||
phone.requestCall#5b95b3d4 user_id:InputUser random_id:int g_a_hash:bytes protocol:PhoneCallProtocol = phone.PhoneCall;
|
||||
phone.requestCall#42ff96ed flags:# video:flags.0?true user_id:InputUser random_id:int g_a_hash:bytes protocol:PhoneCallProtocol = phone.PhoneCall;
|
||||
phone.acceptCall#3bd2b4a0 peer:InputPhoneCall g_b:bytes protocol:PhoneCallProtocol = phone.PhoneCall;
|
||||
phone.confirmCall#2efe1722 peer:InputPhoneCall g_a:bytes key_fingerprint:long protocol:PhoneCallProtocol = phone.PhoneCall;
|
||||
phone.receivedCall#17d54f61 peer:InputPhoneCall = Bool;
|
||||
phone.discardCall#78d413a6 peer:InputPhoneCall duration:int reason:PhoneCallDiscardReason connection_id:long = Updates;
|
||||
phone.discardCall#b2cbc1c0 flags:# video:flags.0?true peer:InputPhoneCall duration:int reason:PhoneCallDiscardReason connection_id:long = Updates;
|
||||
phone.setCallRating#59ead627 flags:# user_initiative:flags.0?true peer:InputPhoneCall rating:int comment:string = Updates;
|
||||
phone.saveCallDebug#277add7e peer:InputPhoneCall debug:DataJSON = Bool;
|
||||
|
||||
|
Binary file not shown.
@ -116,10 +116,11 @@ CallActor::CallActor(CallId call_id, ActorShared<> parent, Promise<int64> promis
|
||||
}
|
||||
|
||||
void CallActor::create_call(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user,
|
||||
CallProtocol &&protocol, Promise<CallId> &&promise) {
|
||||
CallProtocol &&protocol, bool is_video, Promise<CallId> &&promise) {
|
||||
CHECK(state_ == State::Empty);
|
||||
state_ = State::SendRequestQuery;
|
||||
is_outgoing_ = true;
|
||||
is_video_ = is_video;
|
||||
user_id_ = user_id;
|
||||
input_user_ = std::move(input_user);
|
||||
call_state_.protocol = std::move(protocol);
|
||||
@ -130,11 +131,13 @@ void CallActor::create_call(UserId user_id, tl_object_ptr<telegram_api::InputUse
|
||||
promise.set_value(CallId(local_call_id_));
|
||||
}
|
||||
|
||||
void CallActor::discard_call(bool is_disconnected, int32 duration, int64 connection_id, Promise<> promise) {
|
||||
void CallActor::discard_call(bool is_disconnected, int32 duration, bool is_video, int64 connection_id,
|
||||
Promise<> promise) {
|
||||
promise.set_value(Unit());
|
||||
if (state_ == State::Discarded || state_ == State::WaitDiscardResult || state_ == State::SendDiscardQuery) {
|
||||
return;
|
||||
}
|
||||
is_video_ |= is_video;
|
||||
|
||||
if (state_ == State::WaitRequestResult && !request_query_ref_.empty()) {
|
||||
LOG(INFO) << "Cancel request call query";
|
||||
@ -250,7 +253,6 @@ Status CallActor::do_update_call(telegram_api::phoneCallEmpty &call) {
|
||||
return Status::Error(400, "Call is finished");
|
||||
}
|
||||
|
||||
//phoneCallWaiting#1b8f4ad1 flags:# id:long access_hash:long date:int admin_id:int participant_id:int protocol:PhoneCallProtocol receive_date:flags.0?int = PhoneCall;
|
||||
Status CallActor::do_update_call(telegram_api::phoneCallWaiting &call) {
|
||||
if (state_ != State::WaitRequestResult && state_ != State::WaitAcceptResult) {
|
||||
return Status::Error(500, PSLICE() << "Drop unexpected " << to_string(call));
|
||||
@ -272,6 +274,7 @@ Status CallActor::do_update_call(telegram_api::phoneCallWaiting &call) {
|
||||
call_id_ = call.id_;
|
||||
call_access_hash_ = call.access_hash_;
|
||||
is_call_id_inited_ = true;
|
||||
is_video_ |= (call.flags_ & telegram_api::phoneCallWaiting::VIDEO_MASK) != 0;
|
||||
call_admin_id_ = call.admin_id_;
|
||||
call_participant_id_ = call.participant_id_;
|
||||
if (call_id_promise_) {
|
||||
@ -286,7 +289,6 @@ Status CallActor::do_update_call(telegram_api::phoneCallWaiting &call) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
//phoneCallRequested#83761ce4 id:long access_hash:long date:int admin_id:int participant_id:int g_a_hash:bytes protocol:PhoneCallProtocol = PhoneCall;
|
||||
Status CallActor::do_update_call(telegram_api::phoneCallRequested &call) {
|
||||
if (state_ != State::Empty) {
|
||||
return Status::Error(500, PSLICE() << "Drop unexpected " << to_string(call));
|
||||
@ -295,6 +297,7 @@ Status CallActor::do_update_call(telegram_api::phoneCallRequested &call) {
|
||||
call_id_ = call.id_;
|
||||
call_access_hash_ = call.access_hash_;
|
||||
is_call_id_inited_ = true;
|
||||
is_video_ |= (call.flags_ & telegram_api::phoneCallRequested::VIDEO_MASK) != 0;
|
||||
call_admin_id_ = call.admin_id_;
|
||||
call_participant_id_ = call.participant_id_;
|
||||
if (call_id_promise_) {
|
||||
@ -318,7 +321,6 @@ tl_object_ptr<telegram_api::inputPhoneCall> CallActor::get_input_phone_call(cons
|
||||
return make_tl_object<telegram_api::inputPhoneCall>(call_id_, call_access_hash_);
|
||||
}
|
||||
|
||||
//phoneCallAccepted#6d003d3f id:long access_hash:long date:int admin_id:int participant_id:int g_b:bytes protocol:PhoneCallProtocol = PhoneCall;
|
||||
Status CallActor::do_update_call(telegram_api::phoneCallAccepted &call) {
|
||||
if (state_ != State::WaitRequestResult) {
|
||||
return Status::Error(500, PSLICE() << "Drop unexpected " << to_string(call));
|
||||
@ -335,6 +337,7 @@ Status CallActor::do_update_call(telegram_api::phoneCallAccepted &call) {
|
||||
call_id_promise_.set_value(std::move(call.id_));
|
||||
}
|
||||
}
|
||||
is_video_ |= (call.flags_ & telegram_api::phoneCallAccepted::VIDEO_MASK) != 0;
|
||||
dh_handshake_.set_g_a(call.g_b_.as_slice());
|
||||
TRY_STATUS(dh_handshake_.run_checks(true, DhCache::instance()));
|
||||
std::tie(call_state_.key_fingerprint, call_state_.key) = dh_handshake_.gen_key();
|
||||
@ -352,7 +355,6 @@ void CallActor::on_begin_exchanging_key() {
|
||||
set_timeout_in(timeout);
|
||||
}
|
||||
|
||||
//phoneCall#ffe6ab67 id:long access_hash:long date:int admin_id:int participant_id:int g_a_or_b:bytes key_fingerprint:long protocol:PhoneCallProtocol connection:PhoneConnection alternative_connections:Vector<PhoneConnection> start_date:int = PhoneCall;
|
||||
Status CallActor::do_update_call(telegram_api::phoneCall &call) {
|
||||
if (state_ != State::WaitAcceptResult && state_ != State::WaitConfirmResult) {
|
||||
return Status::Error(500, PSLICE() << "Drop unexpected " << to_string(call));
|
||||
@ -372,8 +374,7 @@ Status CallActor::do_update_call(telegram_api::phoneCall &call) {
|
||||
call_state_.emojis_fingerprint =
|
||||
get_emojis_fingerprint(call_state_.key, is_outgoing_ ? dh_handshake_.get_g_b() : dh_handshake_.get_g_a());
|
||||
|
||||
call_state_.connections.push_back(CallConnection::from_telegram_api(*call.connection_));
|
||||
for (auto &connection : call.alternative_connections_) {
|
||||
for (auto &connection : call.connections_) {
|
||||
call_state_.connections.push_back(CallConnection::from_telegram_api(*connection));
|
||||
}
|
||||
call_state_.protocol = CallProtocol::from_telegram_api(*call.protocol_);
|
||||
@ -384,15 +385,15 @@ Status CallActor::do_update_call(telegram_api::phoneCall &call) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
//phoneCallDiscarded#50ca4de1 flags:# need_rating:flags.2?true need_debug:flags.3?true id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = PhoneCall;
|
||||
Status CallActor::do_update_call(telegram_api::phoneCallDiscarded &call) {
|
||||
LOG(DEBUG) << "Do update call to Discarded";
|
||||
on_call_discarded(get_call_discard_reason(call.reason_), call.need_rating_, call.need_debug_);
|
||||
on_call_discarded(get_call_discard_reason(call.reason_), call.need_rating_, call.need_debug_, call.video_);
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
void CallActor::on_call_discarded(CallDiscardReason reason, bool need_rating, bool need_debug) {
|
||||
void CallActor::on_call_discarded(CallDiscardReason reason, bool need_rating, bool need_debug, bool is_video) {
|
||||
state_ = State::Discarded;
|
||||
is_video_ |= is_video;
|
||||
|
||||
if (call_state_.discard_reason == CallDiscardReason::Empty || reason != CallDiscardReason::Empty) {
|
||||
call_state_.discard_reason = reason;
|
||||
@ -508,7 +509,6 @@ void CallActor::on_received_query_result(NetQueryPtr net_query) {
|
||||
}
|
||||
}
|
||||
|
||||
//phone.requestCall#5b95b3d4 user_id:InputUser random_id:int g_a_hash:bytes protocol:PhoneCallProtocol = phone.PhoneCall;
|
||||
void CallActor::try_send_request_query() {
|
||||
LOG(INFO) << "Trying to send request query";
|
||||
if (!load_dh_config()) {
|
||||
@ -516,8 +516,12 @@ void CallActor::try_send_request_query() {
|
||||
}
|
||||
dh_handshake_.set_config(dh_config_->g, dh_config_->prime);
|
||||
CHECK(input_user_ != nullptr);
|
||||
auto tl_query = telegram_api::phone_requestCall(std::move(input_user_), Random::secure_int32(),
|
||||
BufferSlice(dh_handshake_.get_g_b_hash()),
|
||||
int32 flags = 0;
|
||||
if (is_video_) {
|
||||
flags |= telegram_api::phone_requestCall::VIDEO_MASK;
|
||||
}
|
||||
auto tl_query = telegram_api::phone_requestCall(flags, false /*ignored*/, std::move(input_user_),
|
||||
Random::secure_int32(), BufferSlice(dh_handshake_.get_g_b_hash()),
|
||||
call_state_.protocol.as_telegram_api());
|
||||
auto query = G()->net_query_creator().create(create_storer(tl_query));
|
||||
state_ = State::WaitRequestResult;
|
||||
@ -596,14 +600,18 @@ void CallActor::on_confirm_query_result(NetQueryPtr net_query) {
|
||||
void CallActor::try_send_discard_query() {
|
||||
if (call_id_ == 0) {
|
||||
LOG(INFO) << "Failed to send discard query, because call_id_ is unknown";
|
||||
on_call_discarded(CallDiscardReason::Missed, false, false);
|
||||
on_call_discarded(CallDiscardReason::Missed, false, false, is_video_);
|
||||
yield();
|
||||
return;
|
||||
}
|
||||
LOG(INFO) << "Trying to send discard query";
|
||||
auto tl_query =
|
||||
telegram_api::phone_discardCall(get_input_phone_call("try_send_discard_query"), duration_,
|
||||
get_input_phone_call_discard_reason(call_state_.discard_reason), connection_id_);
|
||||
int32 flags = 0;
|
||||
if (is_video_) {
|
||||
flags |= telegram_api::phone_discardCall::VIDEO_MASK;
|
||||
}
|
||||
auto tl_query = telegram_api::phone_discardCall(
|
||||
flags, false /*ignored*/, get_input_phone_call("try_send_discard_query"), duration_,
|
||||
get_input_phone_call_discard_reason(call_state_.discard_reason), connection_id_);
|
||||
auto query = G()->net_query_creator().create(create_storer(tl_query));
|
||||
state_ = State::WaitDiscardResult;
|
||||
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this)](NetQueryPtr net_query) {
|
||||
|
@ -78,8 +78,8 @@ class CallActor : public NetQueryCallback {
|
||||
CallActor(CallId call_id, ActorShared<> parent, Promise<int64> promise);
|
||||
|
||||
void create_call(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user, CallProtocol &&protocol,
|
||||
Promise<CallId> &&promise);
|
||||
void discard_call(bool is_disconnected, int32 duration, int64 connection_id, Promise<> promise);
|
||||
bool is_video, Promise<CallId> &&promise);
|
||||
void discard_call(bool is_disconnected, int32 duration, bool is_video, int64 connection_id, Promise<> promise);
|
||||
void accept_call(CallProtocol &&protocol, Promise<> promise);
|
||||
void rate_call(int32 rating, string comment, Promise<> promise);
|
||||
void send_call_debug_information(string data, Promise<> promise);
|
||||
@ -114,6 +114,7 @@ class CallActor : public NetQueryCallback {
|
||||
bool is_accepted_{false};
|
||||
|
||||
bool is_outgoing_{false};
|
||||
bool is_video_{false};
|
||||
UserId user_id_;
|
||||
tl_object_ptr<telegram_api::InputUser> input_user_;
|
||||
|
||||
@ -160,7 +161,7 @@ class CallActor : public NetQueryCallback {
|
||||
|
||||
void on_begin_exchanging_key();
|
||||
|
||||
void on_call_discarded(CallDiscardReason reason, bool need_rating, bool need_debug);
|
||||
void on_call_discarded(CallDiscardReason reason, bool need_rating, bool need_debug, bool is_video);
|
||||
|
||||
void on_set_rating_query_result(NetQueryPtr net_query);
|
||||
void on_set_debug_query_result(NetQueryPtr net_query);
|
||||
|
@ -45,21 +45,22 @@ void CallManager::update_call(Update call) {
|
||||
}
|
||||
|
||||
void CallManager::create_call(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user,
|
||||
CallProtocol &&protocol, Promise<CallId> promise) {
|
||||
CallProtocol &&protocol, bool is_video, Promise<CallId> promise) {
|
||||
LOG(INFO) << "Create call with " << user_id;
|
||||
auto call_id = create_call_actor();
|
||||
auto actor = get_call_actor(call_id);
|
||||
CHECK(!actor.empty());
|
||||
send_closure(actor, &CallActor::create_call, user_id, std::move(input_user), std::move(protocol), std::move(promise));
|
||||
send_closure(actor, &CallActor::create_call, user_id, std::move(input_user), std::move(protocol), is_video,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void CallManager::discard_call(CallId call_id, bool is_disconnected, int32 duration, int64 connection_id,
|
||||
void CallManager::discard_call(CallId call_id, bool is_disconnected, int32 duration, bool is_video, int64 connection_id,
|
||||
Promise<> promise) {
|
||||
auto actor = get_call_actor(call_id);
|
||||
if (actor.empty()) {
|
||||
return promise.set_error(Status::Error(400, "Call not found"));
|
||||
}
|
||||
send_closure(actor, &CallActor::discard_call, is_disconnected, duration, connection_id, std::move(promise));
|
||||
send_closure(actor, &CallActor::discard_call, is_disconnected, duration, is_video, connection_id, std::move(promise));
|
||||
}
|
||||
|
||||
void CallManager::accept_call(CallId call_id, CallProtocol &&protocol, Promise<> promise) {
|
||||
|
@ -28,8 +28,9 @@ class CallManager : public Actor {
|
||||
void update_call(Update call);
|
||||
|
||||
void create_call(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user, CallProtocol &&protocol,
|
||||
Promise<CallId> promise);
|
||||
void discard_call(CallId call_id, bool is_disconnected, int32 duration, int64 connection_id, Promise<> promise);
|
||||
bool is_video, Promise<CallId> promise);
|
||||
void discard_call(CallId call_id, bool is_disconnected, int32 duration, bool is_video, int64 connection_id,
|
||||
Promise<> promise);
|
||||
void accept_call(CallId call_id, CallProtocol &&protocol, Promise<> promise);
|
||||
void rate_call(CallId call_id, int32 rating, string comment, Promise<> promise);
|
||||
void send_call_debug_information(CallId call_id, string data, Promise<> promise);
|
||||
|
@ -5468,10 +5468,8 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) {
|
||||
telegram_api::user::PHONE_MASK | telegram_api::user::PHOTO_MASK | telegram_api::user::VERIFIED_MASK |
|
||||
telegram_api::user::SUPPORT_MASK;
|
||||
auto profile_photo = telegram_api::make_object<telegram_api::userProfilePhoto>(
|
||||
3337190045231018,
|
||||
telegram_api::make_object<telegram_api::fileLocation>(1, 702229962, 26779, 5859320227133863146, BufferSlice()),
|
||||
telegram_api::make_object<telegram_api::fileLocation>(1, 702229962, 26781, -3695031185685824216,
|
||||
BufferSlice()));
|
||||
3337190045231018, telegram_api::make_object<telegram_api::fileLocationToBeDeprecated>(702229962, 26779),
|
||||
telegram_api::make_object<telegram_api::fileLocationToBeDeprecated>(702229962, 26781), 1);
|
||||
if (G()->is_test_dc()) {
|
||||
profile_photo = nullptr;
|
||||
flags -= telegram_api::user::PHOTO_MASK;
|
||||
@ -6590,7 +6588,7 @@ void ContactsManager::on_get_user_photos(UserId user_id, int32 offset, int32 lim
|
||||
auto server_photo = telegram_api::move_object_as<telegram_api::photo>(photo_ptr);
|
||||
auto profile_photo = convert_photo_to_profile_photo(server_photo);
|
||||
if (profile_photo) {
|
||||
get_profile_photo(td_->file_manager_.get(), std::move(profile_photo));
|
||||
get_profile_photo(td_->file_manager_.get(), user_id, u->access_hash, std::move(profile_photo));
|
||||
} else {
|
||||
LOG(ERROR) << "Failed to get profile photo from " << to_string(server_photo);
|
||||
}
|
||||
@ -6961,19 +6959,6 @@ void ContactsManager::on_update_user_photo(User *u, UserId user_id,
|
||||
tl_object_ptr<telegram_api::UserProfilePhoto> &&photo) {
|
||||
if (td_->auth_manager_->is_bot() && !G()->parameters().use_file_db && !u->is_photo_inited) {
|
||||
bool is_empty = photo == nullptr || photo->get_id() == telegram_api::userProfilePhotoEmpty::ID;
|
||||
if (!is_empty) {
|
||||
CHECK(photo->get_id() == telegram_api::userProfilePhoto::ID);
|
||||
auto user_photo = static_cast<telegram_api::userProfilePhoto *>(photo.get());
|
||||
|
||||
auto copy_location = [](telegram_api::FileLocation *location_ptr) {
|
||||
if (location_ptr->get_id() == telegram_api::fileLocation::ID) {
|
||||
auto location = static_cast<telegram_api::fileLocation *>(location_ptr);
|
||||
location->file_reference_ = location->file_reference_.copy();
|
||||
}
|
||||
};
|
||||
copy_location(user_photo->photo_small_.get());
|
||||
copy_location(user_photo->photo_big_.get());
|
||||
}
|
||||
pending_user_photos_[user_id] = std::move(photo);
|
||||
|
||||
UserFull *user_full = get_user_full(user_id);
|
||||
@ -6995,7 +6980,7 @@ void ContactsManager::on_update_user_photo(User *u, UserId user_id,
|
||||
void ContactsManager::do_update_user_photo(User *u, UserId user_id,
|
||||
tl_object_ptr<telegram_api::UserProfilePhoto> &&photo) {
|
||||
u->is_photo_inited = true;
|
||||
ProfilePhoto new_photo = get_profile_photo(td_->file_manager_.get(), std::move(photo));
|
||||
ProfilePhoto new_photo = get_profile_photo(td_->file_manager_.get(), user_id, u->access_hash, std::move(photo));
|
||||
|
||||
if (new_photo != u->photo) {
|
||||
u->photo = new_photo;
|
||||
@ -8009,7 +7994,13 @@ void ContactsManager::on_get_dialog_invite_link_info(const string &invite_link,
|
||||
invite_link_info->chat_id = ChatId();
|
||||
invite_link_info->channel_id = ChannelId();
|
||||
invite_link_info->title = chat_invite->title_;
|
||||
invite_link_info->photo = get_dialog_photo(td_->file_manager_.get(), std::move(chat_invite->photo_));
|
||||
if (chat_invite->photo_ != nullptr && chat_invite->photo_->get_id() == telegram_api::photo::ID) {
|
||||
auto photo = telegram_api::move_object_as<telegram_api::photo>(chat_invite->photo_);
|
||||
invite_link_info->photo =
|
||||
get_profile_photo(td_->file_manager_.get(), UserId(), 0, convert_photo_to_profile_photo(photo));
|
||||
} else {
|
||||
invite_link_info->photo = DialogPhoto();
|
||||
}
|
||||
invite_link_info->participant_count = chat_invite->participants_count_;
|
||||
invite_link_info->participant_user_ids.clear();
|
||||
for (auto &user : chat_invite->participants_) {
|
||||
@ -8476,7 +8467,8 @@ void ContactsManager::on_update_chat_participant_count(Chat *c, ChatId chat_id,
|
||||
|
||||
void ContactsManager::on_update_chat_photo(Chat *c, ChatId chat_id,
|
||||
tl_object_ptr<telegram_api::ChatPhoto> &&chat_photo_ptr) {
|
||||
DialogPhoto new_chat_photo = get_dialog_photo(td_->file_manager_.get(), std::move(chat_photo_ptr));
|
||||
DialogPhoto new_chat_photo =
|
||||
get_dialog_photo(td_->file_manager_.get(), DialogId(chat_id), 0, std::move(chat_photo_ptr));
|
||||
|
||||
if (new_chat_photo != c->photo) {
|
||||
if (c->photo_source_id.is_valid()) {
|
||||
@ -8601,7 +8593,8 @@ void ContactsManager::invalidate_chat_full(ChatId chat_id) {
|
||||
|
||||
void ContactsManager::on_update_channel_photo(Channel *c, ChannelId channel_id,
|
||||
tl_object_ptr<telegram_api::ChatPhoto> &&chat_photo_ptr) {
|
||||
DialogPhoto new_chat_photo = get_dialog_photo(td_->file_manager_.get(), std::move(chat_photo_ptr));
|
||||
DialogPhoto new_chat_photo =
|
||||
get_dialog_photo(td_->file_manager_.get(), DialogId(channel_id), c->access_hash, std::move(chat_photo_ptr));
|
||||
|
||||
if (new_chat_photo != c->photo) {
|
||||
if (c->photo_source_id.is_valid()) {
|
||||
|
@ -227,8 +227,9 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
|
||||
if (document_type != Document::Type::VoiceNote) {
|
||||
for (auto &thumb : document->thumbs_) {
|
||||
auto photo_size = get_photo_size(td_->file_manager_.get(), FileType::Thumbnail, 0, 0, "", owner_dialog_id,
|
||||
std::move(thumb), has_webp_thumbnail, has_png_thumbnail);
|
||||
auto photo_size = get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, id, access_hash,
|
||||
file_reference, DcId::create(dc_id), owner_dialog_id, std::move(thumb),
|
||||
has_webp_thumbnail, has_png_thumbnail);
|
||||
if (photo_size.get_offset() == 0) {
|
||||
thumbnail = std::move(photo_size.get<0>());
|
||||
} else {
|
||||
|
@ -443,10 +443,11 @@ class MessageCall : public MessageContent {
|
||||
int64 call_id;
|
||||
int32 duration;
|
||||
CallDiscardReason discard_reason;
|
||||
bool is_video;
|
||||
|
||||
MessageCall() = default;
|
||||
MessageCall(int64 call_id, int32 duration, CallDiscardReason discard_reason)
|
||||
: call_id(call_id), duration(duration), discard_reason(discard_reason) {
|
||||
MessageCall(int64 call_id, int32 duration, CallDiscardReason discard_reason, bool is_video)
|
||||
: call_id(call_id), duration(duration), discard_reason(discard_reason), is_video(is_video) {
|
||||
}
|
||||
|
||||
MessageContentType get_type() const override {
|
||||
@ -906,6 +907,9 @@ static void store(const MessageContent *content, StorerT &storer) {
|
||||
}
|
||||
case MessageContentType::Call: {
|
||||
auto m = static_cast<const MessageCall *>(content);
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(m->is_video);
|
||||
END_STORE_FLAGS();
|
||||
store(m->call_id, storer);
|
||||
store(m->duration, storer);
|
||||
store(m->discard_reason, storer);
|
||||
@ -1227,6 +1231,13 @@ static void parse(unique_ptr<MessageContent> &content, ParserT &parser) {
|
||||
}
|
||||
case MessageContentType::Call: {
|
||||
auto m = make_unique<MessageCall>();
|
||||
if (parser.version() >= static_cast<int32>(Version::AddVideoCallsSupport)) {
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(m->is_video);
|
||||
END_PARSE_FLAGS();
|
||||
} else {
|
||||
m->is_video = false;
|
||||
}
|
||||
parse(m->call_id, parser);
|
||||
parse(m->duration, parser);
|
||||
parse(m->discard_reason, parser);
|
||||
@ -2891,10 +2902,9 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
|
||||
CHECK(new_file_view.has_remote_location());
|
||||
CHECK(!new_file_view.remote_location().is_web());
|
||||
FileId file_id = td->file_manager_->register_remote(
|
||||
FullRemoteFileLocation(FileType::Photo, new_file_view.remote_location().get_id(),
|
||||
new_file_view.remote_location().get_access_hash(), 0, 0, 0, DcId::invalid(),
|
||||
new_file_view.remote_location().get_upload_file_reference().str(),
|
||||
new_file_view.remote_location().get_download_file_reference().str()),
|
||||
FullRemoteFileLocation({FileType::Photo, 'i'}, new_file_view.remote_location().get_id(),
|
||||
new_file_view.remote_location().get_access_hash(), 0, 0, DcId::invalid(),
|
||||
new_file_view.remote_location().get_upload_file_reference().str()),
|
||||
FileLocationSource::FromServer, dialog_id, old_photo->photos.back().size, 0, "");
|
||||
LOG_STATUS(td->file_manager_->merge(file_id, old_file_id));
|
||||
}
|
||||
@ -3078,7 +3088,7 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
|
||||
case MessageContentType::Call: {
|
||||
auto old_ = static_cast<const MessageCall *>(old_content);
|
||||
auto new_ = static_cast<const MessageCall *>(new_content);
|
||||
if (old_->call_id != new_->call_id) {
|
||||
if (old_->call_id != new_->call_id || old_->is_video != new_->is_video) {
|
||||
is_content_changed = true;
|
||||
}
|
||||
if (old_->duration != new_->duration || old_->discard_reason != new_->discard_reason) {
|
||||
@ -3330,14 +3340,12 @@ static tl_object_ptr<ToT> secret_to_telegram(FromT &from);
|
||||
|
||||
// fileLocationUnavailable#7c596b46 volume_id:long local_id:int secret:long = FileLocation;
|
||||
static auto secret_to_telegram(secret_api::fileLocationUnavailable &file_location) {
|
||||
return make_tl_object<telegram_api::fileLocationUnavailable>(file_location.volume_id_, file_location.local_id_,
|
||||
file_location.secret_);
|
||||
return make_tl_object<telegram_api::fileLocationToBeDeprecated>(file_location.volume_id_, file_location.local_id_);
|
||||
}
|
||||
|
||||
// fileLocation#53d69076 dc_id:int volume_id:long local_id:int secret:long = FileLocation;
|
||||
static auto secret_to_telegram(secret_api::fileLocation &file_location) {
|
||||
return make_tl_object<telegram_api::fileLocation>(file_location.dc_id_, file_location.volume_id_,
|
||||
file_location.local_id_, file_location.secret_, BufferSlice());
|
||||
return make_tl_object<telegram_api::fileLocationToBeDeprecated>(file_location.volume_id_, file_location.local_id_);
|
||||
}
|
||||
|
||||
// photoSizeEmpty#e17e23c type:string = PhotoSize;
|
||||
@ -3353,9 +3361,9 @@ static auto secret_to_telegram(secret_api::photoSize &photo_size) {
|
||||
if (!clean_input_string(photo_size.type_)) {
|
||||
photo_size.type_.clear();
|
||||
}
|
||||
return make_tl_object<telegram_api::photoSize>(photo_size.type_,
|
||||
secret_to_telegram<telegram_api::FileLocation>(*photo_size.location_),
|
||||
photo_size.w_, photo_size.h_, photo_size.size_);
|
||||
return make_tl_object<telegram_api::photoSize>(
|
||||
photo_size.type_, secret_to_telegram<telegram_api::fileLocationToBeDeprecated>(*photo_size.location_),
|
||||
photo_size.w_, photo_size.h_, photo_size.size_);
|
||||
}
|
||||
|
||||
// photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize;
|
||||
@ -3364,8 +3372,8 @@ static auto secret_to_telegram(secret_api::photoCachedSize &photo_size) {
|
||||
photo_size.type_.clear();
|
||||
}
|
||||
return make_tl_object<telegram_api::photoCachedSize>(
|
||||
photo_size.type_, secret_to_telegram<telegram_api::FileLocation>(*photo_size.location_), photo_size.w_,
|
||||
photo_size.h_, photo_size.bytes_.clone());
|
||||
photo_size.type_, secret_to_telegram<telegram_api::fileLocationToBeDeprecated>(*photo_size.location_),
|
||||
photo_size.w_, photo_size.h_, photo_size.bytes_.clone());
|
||||
}
|
||||
|
||||
// documentAttributeImageSize #6c37c15c w:int h:int = DocumentAttribute;
|
||||
@ -4214,7 +4222,9 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
|
||||
auto phone_call = move_tl_object_as<telegram_api::messageActionPhoneCall>(action);
|
||||
auto duration =
|
||||
(phone_call->flags_ & telegram_api::messageActionPhoneCall::DURATION_MASK) != 0 ? phone_call->duration_ : 0;
|
||||
return make_unique<MessageCall>(phone_call->call_id_, duration, get_call_discard_reason(phone_call->reason_));
|
||||
auto is_video = (phone_call->flags_ & telegram_api::messageActionPhoneCall::VIDEO_MASK) != 0;
|
||||
return make_unique<MessageCall>(phone_call->call_id_, duration, get_call_discard_reason(phone_call->reason_),
|
||||
is_video);
|
||||
}
|
||||
case telegram_api::messageActionPaymentSent::ID: {
|
||||
LOG_IF(ERROR, td->auth_manager_->is_bot()) << "Receive MessageActionPaymentSent in " << owner_dialog_id;
|
||||
|
@ -22185,10 +22185,10 @@ tl_object_ptr<td_api::ChatEventAction> MessagesManager::get_chat_event_action_ob
|
||||
case telegram_api::channelAdminLogEventActionChangePhoto::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangePhoto>(action_ptr);
|
||||
auto file_manager = td_->file_manager_.get();
|
||||
auto old_photo = td::get_dialog_photo(file_manager, std::move(action->prev_photo_));
|
||||
auto new_photo = td::get_dialog_photo(file_manager, std::move(action->new_photo_));
|
||||
return make_tl_object<td_api::chatEventPhotoChanged>(get_chat_photo_object(file_manager, &old_photo),
|
||||
get_chat_photo_object(file_manager, &new_photo));
|
||||
auto old_photo = get_photo(file_manager, std::move(action->prev_photo_), DialogId());
|
||||
auto new_photo = get_photo(file_manager, std::move(action->new_photo_), DialogId());
|
||||
return make_tl_object<td_api::chatEventPhotoChanged>(get_photo_object(file_manager, &old_photo),
|
||||
get_photo_object(file_manager, &new_photo));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionDefaultBannedRights::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionDefaultBannedRights>(action_ptr);
|
||||
|
@ -95,54 +95,24 @@ td_api::object_ptr<td_api::minithumbnail> get_minithumbnail_object(const string
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static FileId register_photo(FileManager *file_manager, FileType file_type, int64 id, int64 access_hash,
|
||||
std::string upload_file_reference,
|
||||
tl_object_ptr<telegram_api::FileLocation> &&location_ptr, DialogId owner_dialog_id,
|
||||
int32 file_size, bool is_webp = false, bool is_png = false) {
|
||||
DcId dc_id;
|
||||
int32 local_id;
|
||||
int64 volume_id;
|
||||
int64 secret;
|
||||
std::string download_file_reference;
|
||||
switch (location_ptr->get_id()) {
|
||||
case telegram_api::fileLocationUnavailable::ID: {
|
||||
auto location = move_tl_object_as<telegram_api::fileLocationUnavailable>(location_ptr);
|
||||
dc_id = DcId::invalid();
|
||||
local_id = location->local_id_;
|
||||
volume_id = location->volume_id_;
|
||||
secret = location->secret_;
|
||||
break;
|
||||
}
|
||||
case telegram_api::fileLocation::ID: {
|
||||
auto location = move_tl_object_as<telegram_api::fileLocation>(location_ptr);
|
||||
if (!DcId::is_valid(location->dc_id_)) {
|
||||
dc_id = DcId::invalid();
|
||||
} else {
|
||||
dc_id = DcId::internal(location->dc_id_);
|
||||
}
|
||||
local_id = location->local_id_;
|
||||
volume_id = location->volume_id_;
|
||||
secret = location->secret_;
|
||||
download_file_reference = location->file_reference_.as_slice().str();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
|
||||
static FileId register_photo(FileManager *file_manager, const PhotoSizeSource &source, int64 id, int64 access_hash,
|
||||
std::string file_reference,
|
||||
tl_object_ptr<telegram_api::fileLocationToBeDeprecated> &&location,
|
||||
DialogId owner_dialog_id, int32 file_size, DcId dc_id, bool is_webp = false,
|
||||
bool is_png = false) {
|
||||
int32 local_id = location->local_id_;
|
||||
int64 volume_id = location->volume_id_;
|
||||
LOG(DEBUG) << "Receive " << (is_webp ? "webp" : (is_png ? "png" : "jpeg")) << " photo of type "
|
||||
<< static_cast<int8>(file_type) << " in [" << dc_id << "," << volume_id << "," << local_id << "]. Id: ("
|
||||
<< id << ", " << access_hash << ")";
|
||||
<< static_cast<int8>(source.file_type) << " in [" << dc_id << "," << volume_id << "," << local_id
|
||||
<< "]. Id: (" << id << ", " << access_hash << ")";
|
||||
auto suggested_name = PSTRING() << static_cast<uint64>(volume_id) << "_" << static_cast<uint64>(local_id)
|
||||
<< (is_webp ? ".webp" : (is_png ? ".png" : ".jpg"));
|
||||
return file_manager->register_remote(FullRemoteFileLocation(file_type, id, access_hash, local_id, volume_id, secret,
|
||||
dc_id, upload_file_reference, download_file_reference),
|
||||
FileLocationSource::FromServer, owner_dialog_id, file_size, 0,
|
||||
std::move(suggested_name));
|
||||
return file_manager->register_remote(
|
||||
FullRemoteFileLocation(source, id, access_hash, local_id, volume_id, dc_id, std::move(file_reference)),
|
||||
FileLocationSource::FromServer, owner_dialog_id, file_size, 0, std::move(suggested_name));
|
||||
}
|
||||
|
||||
ProfilePhoto get_profile_photo(FileManager *file_manager,
|
||||
ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64 user_access_hash,
|
||||
tl_object_ptr<telegram_api::UserProfilePhoto> &&profile_photo_ptr) {
|
||||
ProfilePhoto result;
|
||||
int32 profile_photo_id =
|
||||
@ -153,11 +123,12 @@ ProfilePhoto get_profile_photo(FileManager *file_manager,
|
||||
case telegram_api::userProfilePhoto::ID: {
|
||||
auto profile_photo = move_tl_object_as<telegram_api::userProfilePhoto>(profile_photo_ptr);
|
||||
|
||||
auto dc_id = DcId::create(profile_photo->dc_id_);
|
||||
result.id = profile_photo->photo_id_;
|
||||
result.small_file_id = register_photo(file_manager, FileType::ProfilePhoto, result.id, 0, "",
|
||||
std::move(profile_photo->photo_small_), DialogId(), 0);
|
||||
result.big_file_id = register_photo(file_manager, FileType::ProfilePhoto, result.id, 0, "",
|
||||
std::move(profile_photo->photo_big_), DialogId(), 0);
|
||||
result.small_file_id = register_photo(file_manager, {DialogId(user_id), user_access_hash, false}, result.id, 0,
|
||||
"", std::move(profile_photo->photo_small_), DialogId(), 0, dc_id);
|
||||
result.big_file_id = register_photo(file_manager, {DialogId(user_id), user_access_hash, true}, result.id, 0, "",
|
||||
std::move(profile_photo->photo_big_), DialogId(), 0, dc_id);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -205,7 +176,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const ProfilePhoto &pro
|
||||
<< ", big_file_id = " << profile_photo.big_file_id << ">";
|
||||
}
|
||||
|
||||
DialogPhoto get_dialog_photo(FileManager *file_manager, tl_object_ptr<telegram_api::ChatPhoto> &&chat_photo_ptr) {
|
||||
DialogPhoto get_dialog_photo(FileManager *file_manager, DialogId dialog_id, int64 dialog_access_hash,
|
||||
tl_object_ptr<telegram_api::ChatPhoto> &&chat_photo_ptr) {
|
||||
int32 chat_photo_id = chat_photo_ptr == nullptr ? telegram_api::chatPhotoEmpty::ID : chat_photo_ptr->get_id();
|
||||
|
||||
DialogPhoto result;
|
||||
@ -215,10 +187,11 @@ DialogPhoto get_dialog_photo(FileManager *file_manager, tl_object_ptr<telegram_a
|
||||
case telegram_api::chatPhoto::ID: {
|
||||
auto chat_photo = move_tl_object_as<telegram_api::chatPhoto>(chat_photo_ptr);
|
||||
|
||||
result.small_file_id = register_photo(file_manager, FileType::ProfilePhoto, 0, 0, "",
|
||||
std::move(chat_photo->photo_small_), DialogId(), 0);
|
||||
result.big_file_id = register_photo(file_manager, FileType::ProfilePhoto, 0, 0, "",
|
||||
std::move(chat_photo->photo_big_), DialogId(), 0);
|
||||
auto dc_id = DcId::create(chat_photo->dc_id_);
|
||||
result.small_file_id = register_photo(file_manager, {dialog_id, dialog_access_hash, false}, 0, 0, "",
|
||||
std::move(chat_photo->photo_small_), DialogId(), 0, dc_id);
|
||||
result.big_file_id = register_photo(file_manager, {dialog_id, dialog_access_hash, true}, 0, 0, "",
|
||||
std::move(chat_photo->photo_big_), DialogId(), 0, dc_id);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -249,6 +222,25 @@ vector<FileId> dialog_photo_get_file_ids(const DialogPhoto &dialog_photo) {
|
||||
return result;
|
||||
}
|
||||
|
||||
DialogPhoto as_dialog_photo(const Photo &photo) {
|
||||
DialogPhoto result;
|
||||
if (photo.id != -2) {
|
||||
for (auto &size : photo.photos) {
|
||||
if (size.type == 'a') {
|
||||
result.small_file_id = size.file_id;
|
||||
} else if (size.type == 'c') {
|
||||
result.big_file_id = size.file_id;
|
||||
}
|
||||
}
|
||||
if (!result.small_file_id.is_valid() || !result.big_file_id.is_valid()) {
|
||||
LOG(ERROR) << "Failed to convert " << photo << " to chat photo";
|
||||
return DialogPhoto();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool operator==(const DialogPhoto &lhs, const DialogPhoto &rhs) {
|
||||
return lhs.small_file_id == rhs.small_file_id && lhs.big_file_id == rhs.big_file_id;
|
||||
}
|
||||
@ -276,9 +268,10 @@ PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice
|
||||
auto dc_id = DcId::invalid();
|
||||
auto local_id = Random::secure_int32();
|
||||
auto volume_id = Random::secure_int64();
|
||||
auto secret = 0;
|
||||
|
||||
res.file_id = file_manager->register_remote(
|
||||
FullRemoteFileLocation(FileType::EncryptedThumbnail, 0, 0, local_id, volume_id, secret, dc_id, "", ""),
|
||||
FullRemoteFileLocation(PhotoSizeSource(FileType::EncryptedThumbnail, 't'), 0, 0, local_id, volume_id, dc_id,
|
||||
string()),
|
||||
FileLocationSource::FromServer, owner_dialog_id, res.size, 0,
|
||||
PSTRING() << static_cast<uint64>(volume_id) << "_" << static_cast<uint64>(local_id) << ".jpg");
|
||||
file_manager->set_content(res.file_id, std::move(bytes));
|
||||
@ -286,13 +279,13 @@ PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice
|
||||
return res;
|
||||
}
|
||||
|
||||
Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, FileType file_type, int64 id, int64 access_hash,
|
||||
std::string upload_file_reference, DialogId owner_dialog_id,
|
||||
tl_object_ptr<telegram_api::PhotoSize> &&size_ptr, bool is_webp,
|
||||
bool is_png) {
|
||||
Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id,
|
||||
int64 access_hash, std::string file_reference, DcId dc_id,
|
||||
DialogId owner_dialog_id, tl_object_ptr<telegram_api::PhotoSize> &&size_ptr,
|
||||
bool is_webp, bool is_png) {
|
||||
CHECK(size_ptr != nullptr);
|
||||
|
||||
tl_object_ptr<telegram_api::FileLocation> location_ptr;
|
||||
tl_object_ptr<telegram_api::fileLocationToBeDeprecated> location;
|
||||
string type;
|
||||
PhotoSize res;
|
||||
BufferSlice content;
|
||||
@ -303,7 +296,7 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, FileType fi
|
||||
auto size = move_tl_object_as<telegram_api::photoSize>(size_ptr);
|
||||
|
||||
type = std::move(size->type_);
|
||||
location_ptr = std::move(size->location_);
|
||||
location = std::move(size->location_);
|
||||
res.dimensions = get_dimensions(size->w_, size->h_);
|
||||
res.size = size->size_;
|
||||
|
||||
@ -313,7 +306,7 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, FileType fi
|
||||
auto size = move_tl_object_as<telegram_api::photoCachedSize>(size_ptr);
|
||||
|
||||
type = std::move(size->type_);
|
||||
location_ptr = std::move(size->location_);
|
||||
location = std::move(size->location_);
|
||||
CHECK(size->bytes_.size() <= static_cast<size_t>(std::numeric_limits<int32>::max()));
|
||||
res.dimensions = get_dimensions(size->w_, size->h_);
|
||||
res.size = static_cast<int32>(size->bytes_.size());
|
||||
@ -331,20 +324,23 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, FileType fi
|
||||
break;
|
||||
}
|
||||
|
||||
res.file_id = register_photo(file_manager, file_type, id, access_hash, upload_file_reference, std::move(location_ptr),
|
||||
owner_dialog_id, res.size, is_webp, is_png);
|
||||
if (type.size() != 1) {
|
||||
res.type = 0;
|
||||
LOG(ERROR) << "Wrong photoSize \"" << type << "\" " << res;
|
||||
} else {
|
||||
res.type = static_cast<unsigned char>(type[0]);
|
||||
}
|
||||
if (source.type == PhotoSizeSource::Type::Thumbnail) {
|
||||
source.thumbnail_type = res.type;
|
||||
}
|
||||
|
||||
res.file_id = register_photo(file_manager, source, id, access_hash, file_reference, std::move(location),
|
||||
owner_dialog_id, res.size, dc_id, is_webp, is_png);
|
||||
|
||||
if (!content.empty()) {
|
||||
file_manager->set_content(res.file_id, std::move(content));
|
||||
}
|
||||
|
||||
if (type.size() != 1) {
|
||||
res.type = 0;
|
||||
LOG(ERROR) << "Wrong photoSize " << res;
|
||||
} else {
|
||||
res.type = static_cast<int32>(type[0]);
|
||||
}
|
||||
|
||||
return std::move(res);
|
||||
}
|
||||
|
||||
@ -488,14 +484,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const PhotoSize &photo_
|
||||
|
||||
Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::encryptedFile> &&file,
|
||||
tl_object_ptr<secret_api::decryptedMessageMediaPhoto> &&photo, DialogId owner_dialog_id) {
|
||||
DcId dc_id;
|
||||
if (!DcId::is_valid(file->dc_id_)) {
|
||||
dc_id = DcId::invalid();
|
||||
} else {
|
||||
dc_id = DcId::internal(file->dc_id_);
|
||||
}
|
||||
FileId file_id = file_manager->register_remote(
|
||||
FullRemoteFileLocation(FileType::Encrypted, file->id_, file->access_hash_, dc_id, ""),
|
||||
FullRemoteFileLocation(FileType::Encrypted, file->id_, file->access_hash_, DcId::create(file->dc_id_), string()),
|
||||
FileLocationSource::FromServer, owner_dialog_id, photo->size_, 0,
|
||||
PSTRING() << static_cast<uint64>(file->id_) << ".jpg");
|
||||
file_manager->set_encryption_key(file_id, FileEncryptionKey{photo->key_.as_slice(), photo->iv_.as_slice()});
|
||||
@ -518,6 +508,16 @@ Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::encrypted
|
||||
return res;
|
||||
}
|
||||
|
||||
Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::Photo> &&photo, DialogId owner_dialog_id) {
|
||||
if (photo == nullptr || photo->get_id() == telegram_api::photoEmpty::ID) {
|
||||
Photo result;
|
||||
result.id = -2;
|
||||
return result;
|
||||
}
|
||||
CHECK(photo->get_id() == telegram_api::photo::ID);
|
||||
return get_photo(file_manager, move_tl_object_as<telegram_api::photo>(photo), owner_dialog_id);
|
||||
}
|
||||
|
||||
Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&photo, DialogId owner_dialog_id) {
|
||||
Photo res;
|
||||
|
||||
@ -526,9 +526,9 @@ Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&
|
||||
res.has_stickers = (photo->flags_ & telegram_api::photo::HAS_STICKERS_MASK) != 0;
|
||||
|
||||
for (auto &size_ptr : photo->sizes_) {
|
||||
auto photo_size =
|
||||
get_photo_size(file_manager, FileType::Photo, photo->id_, photo->access_hash_,
|
||||
photo->file_reference_.as_slice().str(), owner_dialog_id, std::move(size_ptr), false, false);
|
||||
auto photo_size = get_photo_size(file_manager, {FileType::Photo, 0}, photo->id_, photo->access_hash_,
|
||||
photo->file_reference_.as_slice().str(), DcId::create(photo->dc_id_),
|
||||
owner_dialog_id, std::move(size_ptr), false, false);
|
||||
if (photo_size.get_offset() == 0) {
|
||||
res.photos.push_back(std::move(photo_size.get<0>()));
|
||||
} else {
|
||||
@ -716,31 +716,20 @@ StringBuilder &operator<<(StringBuilder &string_builder, const Photo &photo) {
|
||||
return string_builder << "[id = " << photo.id << ", photos = " << format::as_array(photo.photos) << "]";
|
||||
}
|
||||
|
||||
static tl_object_ptr<telegram_api::FileLocation> copy_location(
|
||||
const tl_object_ptr<telegram_api::FileLocation> &location_ptr) {
|
||||
CHECK(location_ptr != nullptr);
|
||||
switch (location_ptr->get_id()) {
|
||||
case telegram_api::fileLocationUnavailable::ID: {
|
||||
auto location = static_cast<const telegram_api::fileLocationUnavailable *>(location_ptr.get());
|
||||
return make_tl_object<telegram_api::fileLocationUnavailable>(location->volume_id_, location->local_id_,
|
||||
location->secret_);
|
||||
}
|
||||
case telegram_api::fileLocation::ID: {
|
||||
auto location = static_cast<const telegram_api::fileLocation *>(location_ptr.get());
|
||||
return make_tl_object<telegram_api::fileLocation>(location->dc_id_, location->volume_id_, location->local_id_,
|
||||
location->secret_, location->file_reference_.clone());
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
static tl_object_ptr<telegram_api::fileLocationToBeDeprecated> copy_location(
|
||||
const tl_object_ptr<telegram_api::fileLocationToBeDeprecated> &location) {
|
||||
CHECK(location != nullptr);
|
||||
return make_tl_object<telegram_api::fileLocationToBeDeprecated>(location->volume_id_, location->local_id_);
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::userProfilePhoto> convert_photo_to_profile_photo(
|
||||
const tl_object_ptr<telegram_api::photo> &photo) {
|
||||
CHECK(photo != nullptr);
|
||||
tl_object_ptr<telegram_api::FileLocation> photo_small;
|
||||
tl_object_ptr<telegram_api::FileLocation> photo_big;
|
||||
if (photo == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::fileLocationToBeDeprecated> photo_small;
|
||||
tl_object_ptr<telegram_api::fileLocationToBeDeprecated> photo_big;
|
||||
for (auto &size_ptr : photo->sizes_) {
|
||||
switch (size_ptr->get_id()) {
|
||||
case telegram_api::photoSizeEmpty::ID:
|
||||
@ -773,7 +762,8 @@ tl_object_ptr<telegram_api::userProfilePhoto> convert_photo_to_profile_photo(
|
||||
if (photo_small == nullptr || photo_big == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<telegram_api::userProfilePhoto>(photo->id_, std::move(photo_small), std::move(photo_big));
|
||||
return make_tl_object<telegram_api::userProfilePhoto>(photo->id_, std::move(photo_small), std::move(photo_big),
|
||||
photo->dc_id_);
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -9,7 +9,9 @@
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/SecretInputMedia.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
|
||||
#include "td/telegram/secret_api.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
@ -45,6 +47,41 @@ struct PhotoSize {
|
||||
FileId file_id;
|
||||
};
|
||||
|
||||
struct PhotoSizeSource {
|
||||
enum class Type : int32 { Thumbnail, DialogPhoto, StickerSetThumbnail };
|
||||
Type type;
|
||||
FileType file_type;
|
||||
|
||||
// for photos, document thumbnails, encrypted thumbnails
|
||||
int32 thumbnail_type = 0;
|
||||
|
||||
// for dialog photos
|
||||
DialogId dialog_id;
|
||||
int64 dialog_access_hash = 0;
|
||||
bool is_big = false;
|
||||
|
||||
// for sticker set thumbnails
|
||||
int64 sticker_set_id = 0;
|
||||
int64 sticker_set_access_hash = 0;
|
||||
|
||||
PhotoSizeSource(FileType file_type, int32 thumbnail_type)
|
||||
: type(Type::Thumbnail), file_type(file_type), thumbnail_type(thumbnail_type) {
|
||||
}
|
||||
PhotoSizeSource(DialogId dialog_id, int64 dialog_access_hash, bool is_big)
|
||||
: type(Type::DialogPhoto)
|
||||
, file_type(FileType::ProfilePhoto)
|
||||
, dialog_id(dialog_id)
|
||||
, dialog_access_hash(dialog_access_hash)
|
||||
, is_big(is_big) {
|
||||
}
|
||||
PhotoSizeSource(int64 sticker_set_id, int64 sticker_set_access_hash)
|
||||
: type(Type::StickerSetThumbnail)
|
||||
, file_type(FileType::Thumbnail)
|
||||
, sticker_set_id(sticker_set_id)
|
||||
, sticker_set_access_hash(sticker_set_access_hash) {
|
||||
}
|
||||
};
|
||||
|
||||
struct Photo {
|
||||
int64 id = 0;
|
||||
int32 date = 0;
|
||||
@ -64,7 +101,7 @@ StringBuilder &operator<<(StringBuilder &string_builder, const Dimensions &dimen
|
||||
|
||||
td_api::object_ptr<td_api::minithumbnail> get_minithumbnail_object(const string &packed);
|
||||
|
||||
ProfilePhoto get_profile_photo(FileManager *file_manager,
|
||||
ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64 user_access_hash,
|
||||
tl_object_ptr<telegram_api::UserProfilePhoto> &&profile_photo_ptr);
|
||||
tl_object_ptr<td_api::profilePhoto> get_profile_photo_object(FileManager *file_manager,
|
||||
const ProfilePhoto *profile_photo);
|
||||
@ -74,9 +111,12 @@ bool operator!=(const ProfilePhoto &lhs, const ProfilePhoto &rhs);
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const ProfilePhoto &profile_photo);
|
||||
|
||||
DialogPhoto get_dialog_photo(FileManager *file_manager, tl_object_ptr<telegram_api::ChatPhoto> &&chat_photo_ptr);
|
||||
DialogPhoto get_dialog_photo(FileManager *file_manager, DialogId dialog_id, int64 dialog_access_hash,
|
||||
tl_object_ptr<telegram_api::ChatPhoto> &&chat_photo_ptr);
|
||||
tl_object_ptr<td_api::chatPhoto> get_chat_photo_object(FileManager *file_manager, const DialogPhoto *dialog_photo);
|
||||
|
||||
DialogPhoto as_dialog_photo(const Photo &photo);
|
||||
|
||||
vector<FileId> dialog_photo_get_file_ids(const DialogPhoto &dialog_photo);
|
||||
|
||||
bool operator==(const DialogPhoto &lhs, const DialogPhoto &rhs);
|
||||
@ -86,9 +126,10 @@ StringBuilder &operator<<(StringBuilder &string_builder, const DialogPhoto &dial
|
||||
|
||||
PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice bytes, DialogId owner_dialog_id,
|
||||
int32 width, int32 height);
|
||||
Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, FileType file_type, int64 id, int64 access_hash,
|
||||
std::string upload_file_reference, DialogId owner_dialog_id,
|
||||
tl_object_ptr<telegram_api::PhotoSize> &&size_ptr, bool is_webp, bool is_png);
|
||||
Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id,
|
||||
int64 access_hash, string file_reference, DcId dc_id,
|
||||
DialogId owner_dialog_id, tl_object_ptr<telegram_api::PhotoSize> &&size_ptr,
|
||||
bool is_webp, bool is_png);
|
||||
PhotoSize get_web_document_photo_size(FileManager *file_manager, FileType file_type, DialogId owner_dialog_id,
|
||||
tl_object_ptr<telegram_api::WebDocument> web_document_ptr);
|
||||
td_api::object_ptr<td_api::photoSize> get_photo_size_object(FileManager *file_manager, const PhotoSize *photo_size);
|
||||
@ -102,6 +143,7 @@ bool operator<(const PhotoSize &lhs, const PhotoSize &rhs);
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const PhotoSize &photo_size);
|
||||
|
||||
Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::Photo> &&photo, DialogId owner_dialog_id);
|
||||
Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&photo, DialogId owner_dialog_id);
|
||||
Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::encryptedFile> &&file,
|
||||
tl_object_ptr<secret_api::decryptedMessageMediaPhoto> &&photo, DialogId owner_dialog_id);
|
||||
|
@ -1248,6 +1248,7 @@ std::pair<int64, FileId> StickersManager::on_get_sticker_document(tl_object_ptr<
|
||||
LOG(ERROR) << "Wrong dc_id = " << document->dc_id_ << " in document " << to_string(document);
|
||||
return {};
|
||||
}
|
||||
auto dc_id = DcId::internal(document->dc_id_);
|
||||
|
||||
Dimensions dimensions;
|
||||
tl_object_ptr<telegram_api::documentAttributeSticker> sticker;
|
||||
@ -1272,13 +1273,13 @@ std::pair<int64, FileId> StickersManager::on_get_sticker_document(tl_object_ptr<
|
||||
|
||||
int64 document_id = document->id_;
|
||||
FileId sticker_id = td_->file_manager_->register_remote(
|
||||
FullRemoteFileLocation(FileType::Sticker, document_id, document->access_hash_, DcId::internal(document->dc_id_),
|
||||
FullRemoteFileLocation(FileType::Sticker, document_id, document->access_hash_, dc_id,
|
||||
document->file_reference_.as_slice().str()),
|
||||
FileLocationSource::FromServer, DialogId(), document->size_, 0, PSTRING() << document_id << ".webp");
|
||||
|
||||
PhotoSize thumbnail;
|
||||
for (auto &thumb : document->thumbs_) {
|
||||
auto photo_size = get_photo_size(td_->file_manager_.get(), FileType::Thumbnail, 0, 0, "", DialogId(),
|
||||
auto photo_size = get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, 0, 0, "", dc_id, DialogId(),
|
||||
std::move(thumb), has_webp_thumbnail(sticker), false);
|
||||
if (photo_size.get_offset() == 0) {
|
||||
thumbnail = std::move(photo_size.get<0>());
|
||||
@ -1732,8 +1733,8 @@ int64 StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::stickerSet
|
||||
|
||||
PhotoSize thumbnail;
|
||||
if (set->thumb_ != nullptr) {
|
||||
auto photo_size = get_photo_size(td_->file_manager_.get(), FileType::Thumbnail, 0, 0, "", DialogId(),
|
||||
std::move(set->thumb_), true, false);
|
||||
auto photo_size = get_photo_size(td_->file_manager_.get(), {set_id, s->access_hash}, 0, 0, "",
|
||||
DcId::create(set->thumb_dc_id_), DialogId(), std::move(set->thumb_), true, false);
|
||||
if (photo_size.get_offset() == 0) {
|
||||
thumbnail = std::move(photo_size.get<0>());
|
||||
} else {
|
||||
|
@ -5736,14 +5736,14 @@ void Td::on_request(uint64 id, td_api::createCall &request) {
|
||||
}
|
||||
|
||||
send_closure(G()->call_manager(), &CallManager::create_call, user_id, std::move(input_user),
|
||||
CallProtocol::from_td_api(*request.protocol_), std::move(query_promise));
|
||||
CallProtocol::from_td_api(*request.protocol_), false, std::move(query_promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::discardCall &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
send_closure(G()->call_manager(), &CallManager::discard_call, CallId(request.call_id_), request.is_disconnected_,
|
||||
request.duration_, request.connection_id_, std::move(promise));
|
||||
request.duration_, false, request.connection_id_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::acceptCall &request) {
|
||||
|
@ -30,6 +30,7 @@ enum class Version : int32 {
|
||||
SupportInstantView2_0,
|
||||
AddNotificationGroupInfoMaxRemovedMessageId,
|
||||
SupportMinithumbnails,
|
||||
AddVideoCallsSupport,
|
||||
Next
|
||||
};
|
||||
|
||||
|
@ -2023,8 +2023,11 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
|
||||
*td->contacts_manager_->get_channel_dialog_photo(channel_id),
|
||||
td->contacts_manager_->get_channel_username(channel_id));
|
||||
} else {
|
||||
bool has_access_hash = (channel->flags_ & telegram_api::channel::ACCESS_HASH_MASK) != 0;
|
||||
return td::make_unique<WebPageBlockChatLink>(
|
||||
std::move(channel->title_), get_dialog_photo(td->file_manager_.get(), std::move(channel->photo_)),
|
||||
std::move(channel->title_),
|
||||
get_dialog_photo(td->file_manager_.get(), DialogId(channel_id),
|
||||
has_access_hash ? channel->access_hash_ : 0, std::move(channel->photo_)),
|
||||
std::move(channel->username_));
|
||||
}
|
||||
} else {
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "td/telegram/files/FileBitmask.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
|
||||
#include "td/utils/base64.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -345,6 +346,14 @@ class FullRemoteFileLocation {
|
||||
return type;
|
||||
}
|
||||
|
||||
void check_file_reference() {
|
||||
FileReferenceView view(file_reference_);
|
||||
if (!(view.has_upload() && view.has_download())) {
|
||||
LOG(ERROR) << "Tried to register file with invalid file reference";
|
||||
file_reference_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const;
|
||||
@ -476,7 +485,8 @@ class FullRemoteFileLocation {
|
||||
return make_tl_object<telegram_api::inputSecureFileLocation>(common().id_, common().access_hash_);
|
||||
} else {
|
||||
return make_tl_object<telegram_api::inputDocumentFileLocation>(
|
||||
common().id_, common().access_hash_, BufferSlice(FileReferenceView(file_reference_).download()));
|
||||
common().id_, common().access_hash_, BufferSlice(FileReferenceView(file_reference_).download()),
|
||||
string());
|
||||
}
|
||||
case LocationType::Web:
|
||||
case LocationType::None:
|
||||
@ -514,31 +524,29 @@ class FullRemoteFileLocation {
|
||||
|
||||
// TODO: this constructor is just for immediate unserialize
|
||||
FullRemoteFileLocation() = default;
|
||||
FullRemoteFileLocation(FileType file_type, int64 id, int64 access_hash, int32 local_id, int64 volume_id, int64 secret,
|
||||
DcId dc_id, std::string upload_file_reference, std::string download_file_reference)
|
||||
: file_type_(file_type)
|
||||
|
||||
// photo
|
||||
FullRemoteFileLocation(const PhotoSizeSource &source, int64 id, int64 access_hash, int32 local_id, int64 volume_id,
|
||||
DcId dc_id, std::string file_reference)
|
||||
: file_type_(source.file_type)
|
||||
, dc_id_(dc_id)
|
||||
, file_reference_(FileReferenceView::create_two(upload_file_reference, download_file_reference))
|
||||
, variant_(PhotoRemoteFileLocation{id, access_hash, volume_id, secret, local_id}) {
|
||||
, file_reference_(FileReferenceView::create_one(file_reference))
|
||||
, variant_(PhotoRemoteFileLocation{id, access_hash, volume_id, -1, local_id}) { // TODO(now) use source
|
||||
CHECK(is_photo());
|
||||
FileReferenceView view(file_reference_);
|
||||
if (!(view.has_upload() && view.has_download())) {
|
||||
LOG(ERROR) << "Tried to register file with invalid file reference";
|
||||
file_reference_.clear();
|
||||
}
|
||||
check_file_reference();
|
||||
}
|
||||
|
||||
// document
|
||||
FullRemoteFileLocation(FileType file_type, int64 id, int64 access_hash, DcId dc_id, std::string file_reference)
|
||||
: file_type_(file_type)
|
||||
, dc_id_(dc_id)
|
||||
, file_reference_(FileReferenceView::create_one(file_reference))
|
||||
, variant_(CommonRemoteFileLocation{id, access_hash}) {
|
||||
CHECK(is_common());
|
||||
FileReferenceView view(file_reference_);
|
||||
if (!(view.has_upload() && view.has_download())) {
|
||||
LOG(ERROR) << "Tried to register file with invalid file reference";
|
||||
file_reference_.clear();
|
||||
}
|
||||
check_file_reference();
|
||||
}
|
||||
|
||||
// web document
|
||||
FullRemoteFileLocation(FileType file_type, string url, int64 access_hash)
|
||||
: file_type_(file_type)
|
||||
, web_location_flag_{true}
|
||||
@ -648,14 +656,6 @@ class RemoteFileLocation {
|
||||
}
|
||||
explicit RemoteFileLocation(const PartialRemoteFileLocation &partial) : variant_(partial) {
|
||||
}
|
||||
RemoteFileLocation(FileType file_type, int64 id, int64 access_hash, int32 local_id, int64 volume_id, int64 secret,
|
||||
DcId dc_id, std::string upload_file_reference, std::string download_file_reference)
|
||||
: variant_(FullRemoteFileLocation{file_type, id, access_hash, local_id, volume_id, secret, dc_id,
|
||||
std::move(upload_file_reference), std::move(download_file_reference)}) {
|
||||
}
|
||||
RemoteFileLocation(FileType file_type, int64 id, int64 access_hash, DcId dc_id, std::string file_reference)
|
||||
: variant_(FullRemoteFileLocation{file_type, id, access_hash, dc_id, std::move(file_reference)}) {
|
||||
}
|
||||
|
||||
private:
|
||||
Variant<EmptyRemoteFileLocation, PartialRemoteFileLocation, FullRemoteFileLocation> variant_;
|
||||
|
@ -40,6 +40,13 @@ class DcId {
|
||||
static DcId from_value(int32 value) {
|
||||
return DcId{value, false};
|
||||
}
|
||||
static DcId create(int32 dc_id_value) {
|
||||
if (DcId::is_valid(dc_id_value)) {
|
||||
return DcId(dc_id_value, true);
|
||||
} else {
|
||||
return DcId::invalid();
|
||||
}
|
||||
}
|
||||
|
||||
bool is_empty() const {
|
||||
return !is_valid();
|
||||
|
@ -21,7 +21,7 @@ class HeaderStorer {
|
||||
}
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
constexpr int32 LAYER = 97;
|
||||
constexpr int32 LAYER = 98;
|
||||
|
||||
using td::store;
|
||||
// invokeWithLayer#da9b0d0d {X:Type} layer:int query:!X = X;
|
||||
|
Loading…
Reference in New Issue
Block a user