Fix has_input_media.
GitOrigin-RevId: f10ffc8116028849b3a0afc4ebf7169d707dd794
This commit is contained in:
parent
e0d303095f
commit
536def0382
@ -330,10 +330,14 @@ const DocumentsManager::Document *DocumentsManager::get_document(FileId file_id)
|
|||||||
return document->second.get();
|
return document->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DocumentsManager::has_input_media(FileId file_id, bool is_secret) const {
|
bool DocumentsManager::has_input_media(FileId file_id, FileId thumbnail_file_id, bool is_secret) const {
|
||||||
auto file_view = td_->file_manager_->get_file_view(file_id);
|
auto file_view = td_->file_manager_->get_file_view(file_id);
|
||||||
if (is_secret) {
|
if (is_secret) {
|
||||||
return file_view.is_encrypted() && file_view.has_remote_location();
|
if (file_view.encryption_key().empty() || !file_view.has_remote_location()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !thumbnail_file_id.is_valid();
|
||||||
} else {
|
} else {
|
||||||
if (file_view.is_encrypted()) {
|
if (file_view.is_encrypted()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -67,7 +67,7 @@ class DocumentsManager {
|
|||||||
|
|
||||||
void create_document(FileId file_id, PhotoSize thumbnail, string file_name, string mime_type, bool replace);
|
void create_document(FileId file_id, PhotoSize thumbnail, string file_name, string mime_type, bool replace);
|
||||||
|
|
||||||
bool has_input_media(FileId file_id, bool is_secret) const;
|
bool has_input_media(FileId file_id, FileId thumbnail_file_id, bool is_secret) const;
|
||||||
|
|
||||||
SecretInputMedia get_secret_input_media(FileId document_file_id,
|
SecretInputMedia get_secret_input_media(FileId document_file_id,
|
||||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||||
|
@ -6310,6 +6310,7 @@ void MessagesManager::after_get_difference() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (td_->is_online()) {
|
||||||
// TODO move to AnimationsManager
|
// TODO move to AnimationsManager
|
||||||
td_->animations_manager_->get_saved_animations(Auto());
|
td_->animations_manager_->get_saved_animations(Auto());
|
||||||
|
|
||||||
@ -6320,6 +6321,7 @@ void MessagesManager::after_get_difference() {
|
|||||||
td_->stickers_manager_->get_recent_stickers(false, Auto());
|
td_->stickers_manager_->get_recent_stickers(false, Auto());
|
||||||
td_->stickers_manager_->get_recent_stickers(true, Auto());
|
td_->stickers_manager_->get_recent_stickers(true, Auto());
|
||||||
td_->stickers_manager_->get_favorite_stickers(Auto());
|
td_->stickers_manager_->get_favorite_stickers(Auto());
|
||||||
|
}
|
||||||
|
|
||||||
load_notification_settings();
|
load_notification_settings();
|
||||||
|
|
||||||
@ -20342,10 +20344,14 @@ unique_ptr<MessageContent> MessagesManager::dup_message_content(DialogId dialog_
|
|||||||
return file_manager->dup_file_id(file_id);
|
return file_manager->dup_file_id(file_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FileId thumbnail_file_id;
|
||||||
|
if (to_secret) {
|
||||||
|
thumbnail_file_id = get_message_content_thumbnail_file_id(content);
|
||||||
|
}
|
||||||
switch (content->get_id()) {
|
switch (content->get_id()) {
|
||||||
case MessageAnimation::ID: {
|
case MessageAnimation::ID: {
|
||||||
auto result = make_unique<MessageAnimation>(*static_cast<const MessageAnimation *>(content));
|
auto result = make_unique<MessageAnimation>(*static_cast<const MessageAnimation *>(content));
|
||||||
if (td_->documents_manager_->has_input_media(result->file_id, to_secret)) {
|
if (td_->documents_manager_->has_input_media(result->file_id, thumbnail_file_id, to_secret)) {
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
result->file_id = td_->animations_manager_->dup_animation(fix_file_id(result->file_id), result->file_id);
|
result->file_id = td_->animations_manager_->dup_animation(fix_file_id(result->file_id), result->file_id);
|
||||||
@ -20354,7 +20360,7 @@ unique_ptr<MessageContent> MessagesManager::dup_message_content(DialogId dialog_
|
|||||||
}
|
}
|
||||||
case MessageAudio::ID: {
|
case MessageAudio::ID: {
|
||||||
auto result = make_unique<MessageAudio>(*static_cast<const MessageAudio *>(content));
|
auto result = make_unique<MessageAudio>(*static_cast<const MessageAudio *>(content));
|
||||||
if (td_->documents_manager_->has_input_media(result->file_id, to_secret)) {
|
if (td_->documents_manager_->has_input_media(result->file_id, thumbnail_file_id, to_secret)) {
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
result->file_id = td_->audios_manager_->dup_audio(fix_file_id(result->file_id), result->file_id);
|
result->file_id = td_->audios_manager_->dup_audio(fix_file_id(result->file_id), result->file_id);
|
||||||
@ -20365,7 +20371,7 @@ unique_ptr<MessageContent> MessagesManager::dup_message_content(DialogId dialog_
|
|||||||
return make_unique<MessageContact>(*static_cast<const MessageContact *>(content));
|
return make_unique<MessageContact>(*static_cast<const MessageContact *>(content));
|
||||||
case MessageDocument::ID: {
|
case MessageDocument::ID: {
|
||||||
auto result = make_unique<MessageDocument>(*static_cast<const MessageDocument *>(content));
|
auto result = make_unique<MessageDocument>(*static_cast<const MessageDocument *>(content));
|
||||||
if (td_->documents_manager_->has_input_media(result->file_id, to_secret)) {
|
if (td_->documents_manager_->has_input_media(result->file_id, thumbnail_file_id, to_secret)) {
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
result->file_id = td_->documents_manager_->dup_document(fix_file_id(result->file_id), result->file_id);
|
result->file_id = td_->documents_manager_->dup_document(fix_file_id(result->file_id), result->file_id);
|
||||||
@ -20436,6 +20442,9 @@ unique_ptr<MessageContent> MessagesManager::dup_message_content(DialogId dialog_
|
|||||||
}
|
}
|
||||||
|
|
||||||
result->photo.photos.back().file_id = fix_file_id(result->photo.photos.back().file_id);
|
result->photo.photos.back().file_id = fix_file_id(result->photo.photos.back().file_id);
|
||||||
|
if (thumbnail.type != 0) {
|
||||||
|
result->photo.photos[0].file_id = td_->file_manager_->dup_file_id(result->photo.photos[0].file_id);
|
||||||
|
}
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
case MessageSticker::ID: {
|
case MessageSticker::ID: {
|
||||||
@ -20453,7 +20462,7 @@ unique_ptr<MessageContent> MessagesManager::dup_message_content(DialogId dialog_
|
|||||||
return make_unique<MessageVenue>(*static_cast<const MessageVenue *>(content));
|
return make_unique<MessageVenue>(*static_cast<const MessageVenue *>(content));
|
||||||
case MessageVideo::ID: {
|
case MessageVideo::ID: {
|
||||||
auto result = make_unique<MessageVideo>(*static_cast<const MessageVideo *>(content));
|
auto result = make_unique<MessageVideo>(*static_cast<const MessageVideo *>(content));
|
||||||
if (td_->documents_manager_->has_input_media(result->file_id, to_secret)) {
|
if (td_->documents_manager_->has_input_media(result->file_id, thumbnail_file_id, to_secret)) {
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
result->file_id = td_->videos_manager_->dup_video(fix_file_id(result->file_id), result->file_id);
|
result->file_id = td_->videos_manager_->dup_video(fix_file_id(result->file_id), result->file_id);
|
||||||
@ -20463,7 +20472,7 @@ unique_ptr<MessageContent> MessagesManager::dup_message_content(DialogId dialog_
|
|||||||
case MessageVideoNote::ID: {
|
case MessageVideoNote::ID: {
|
||||||
auto result = make_unique<MessageVideoNote>(*static_cast<const MessageVideoNote *>(content));
|
auto result = make_unique<MessageVideoNote>(*static_cast<const MessageVideoNote *>(content));
|
||||||
result->is_viewed = false;
|
result->is_viewed = false;
|
||||||
if (td_->documents_manager_->has_input_media(result->file_id, to_secret)) {
|
if (td_->documents_manager_->has_input_media(result->file_id, thumbnail_file_id, to_secret)) {
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
result->file_id = td_->video_notes_manager_->dup_video_note(fix_file_id(result->file_id), result->file_id);
|
result->file_id = td_->video_notes_manager_->dup_video_note(fix_file_id(result->file_id), result->file_id);
|
||||||
@ -20473,7 +20482,7 @@ unique_ptr<MessageContent> MessagesManager::dup_message_content(DialogId dialog_
|
|||||||
case MessageVoiceNote::ID: {
|
case MessageVoiceNote::ID: {
|
||||||
auto result = make_unique<MessageVoiceNote>(*static_cast<const MessageVoiceNote *>(content));
|
auto result = make_unique<MessageVoiceNote>(*static_cast<const MessageVoiceNote *>(content));
|
||||||
result->is_listened = false;
|
result->is_listened = false;
|
||||||
if (td_->documents_manager_->has_input_media(result->file_id, to_secret)) {
|
if (td_->documents_manager_->has_input_media(result->file_id, thumbnail_file_id, to_secret)) {
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
result->file_id = td_->voice_notes_manager_->dup_voice_note(fix_file_id(result->file_id), result->file_id);
|
result->file_id = td_->voice_notes_manager_->dup_voice_note(fix_file_id(result->file_id), result->file_id);
|
||||||
|
@ -386,7 +386,17 @@ bool photo_has_input_media(FileManager *file_manager, const Photo &photo, bool i
|
|||||||
auto file_id = photo.photos.back().file_id;
|
auto file_id = photo.photos.back().file_id;
|
||||||
auto file_view = file_manager->get_file_view(file_id);
|
auto file_view = file_manager->get_file_view(file_id);
|
||||||
if (is_secret) {
|
if (is_secret) {
|
||||||
return file_view.is_encrypted() && file_view.has_remote_location();
|
if (file_view.encryption_key().empty() || !file_view.has_remote_location()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &size : photo.photos) {
|
||||||
|
if (size.type == 't' && size.file_id.is_valid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (file_view.is_encrypted()) {
|
if (file_view.is_encrypted()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1687,6 +1687,7 @@ void SecretChatActor::on_outbound_outer_send_message_promise(uint64 state_id, Pr
|
|||||||
LOG(INFO) << "Outbound secret message [TODO] " << tag("logevent_id", state->message->logevent_id());
|
LOG(INFO) << "Outbound secret message [TODO] " << tag("logevent_id", state->message->logevent_id());
|
||||||
promise.set_value(Unit()); // Seems like this message is at least stored to binlog already
|
promise.set_value(Unit()); // Seems like this message is at least stored to binlog already
|
||||||
}
|
}
|
||||||
|
|
||||||
void SecretChatActor::outbound_loop(OutboundMessageState *state, uint64 state_id) {
|
void SecretChatActor::outbound_loop(OutboundMessageState *state, uint64 state_id) {
|
||||||
if (close_flag_) {
|
if (close_flag_) {
|
||||||
return;
|
return;
|
||||||
|
@ -1229,7 +1229,7 @@ bool StickersManager::has_input_media(FileId sticker_file_id, bool is_secret) co
|
|||||||
auto file_view = td_->file_manager_->get_file_view(sticker_file_id);
|
auto file_view = td_->file_manager_->get_file_view(sticker_file_id);
|
||||||
if (is_secret) {
|
if (is_secret) {
|
||||||
if (file_view.is_encrypted()) {
|
if (file_view.is_encrypted()) {
|
||||||
if (file_view.has_remote_location()) {
|
if (file_view.has_remote_location() && !sticker->message_thumbnail.file_id.is_valid()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -3562,6 +3562,10 @@ void Td::on_channel_unban_timeout(int64 channel_id_long) {
|
|||||||
contacts_manager_->on_channel_unban_timeout(ChannelId(narrow_cast<int32>(channel_id_long)));
|
contacts_manager_->on_channel_unban_timeout(ChannelId(narrow_cast<int32>(channel_id_long)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Td::is_online() const {
|
||||||
|
return is_online_;
|
||||||
|
}
|
||||||
|
|
||||||
void Td::request(uint64 id, tl_object_ptr<td_api::Function> function) {
|
void Td::request(uint64 id, tl_object_ptr<td_api::Function> function) {
|
||||||
request_set_.insert(id);
|
request_set_.insert(id);
|
||||||
|
|
||||||
|
@ -97,6 +97,8 @@ class Td final : public NetQueryCallback {
|
|||||||
|
|
||||||
void on_channel_unban_timeout(int64 channel_id_long);
|
void on_channel_unban_timeout(int64 channel_id_long);
|
||||||
|
|
||||||
|
bool is_online() const;
|
||||||
|
|
||||||
template <class ActorT, class... ArgsT>
|
template <class ActorT, class... ArgsT>
|
||||||
ActorId<ActorT> create_net_actor(ArgsT &&... args) {
|
ActorId<ActorT> create_net_actor(ArgsT &&... args) {
|
||||||
auto slot_id = request_actors_.create(ActorOwn<>(), RequestActorIdType);
|
auto slot_id = request_actors_.create(ActorOwn<>(), RequestActorIdType);
|
||||||
|
Reference in New Issue
Block a user