diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index be2a0ec438..4a901f5d42 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -3444,6 +3444,54 @@ void ApiWrap::forwardMessages( if (item->isSavedMusicItem()) { SendExistingDocument(MessageToSend(action), item->media()->document()); i = draft.items.erase(i); + } else if ([&] { + const auto sourcePeer = item->history()->peer; + if (const auto channel = sourcePeer->asChannel()) { + if (channel->flags() & ChannelData::Flag::NoForwards) return true; + } else if (const auto chat = sourcePeer->asChat()) { + if (chat->flags() & ChatData::Flag::NoForwards) return true; + } else if (const auto user = sourcePeer->asUser()) { + if (user->flags() & UserDataFlag::NoForwardsPeerEnabled) return true; + } + return false; + }()) { + const auto media = item->media(); + const auto caption = TextWithTags{ item->originalText().text }; + const auto to = FileLoadTaskOptions(action); + if (media && media->document()) { + const auto document = media->document(); + const auto path = document->filepath(true); + if (!path.isEmpty()) { + _fileLoader->addTask( + std::make_unique(FileLoadTask::Args{ + .session = &session(), + .filepath = path, + .content = QByteArray(), + .information = nullptr, + .videoCover = nullptr, + .type = SendMediaType::File, + .to = to, + .caption = caption, + .spoiler = false, + .album = nullptr, + .forceFile = false, + .idOverride = 0, + })); + } else { + auto msg = MessageToSend(action); + msg.textWithTags = caption; + SendExistingDocument(std::move(msg), document); + } + } else if (media && media->photo()) { + auto msg = MessageToSend(action); + msg.textWithTags = caption; + SendExistingPhoto(std::move(msg), media->photo()); + } else { + auto msg = MessageToSend(action); + msg.textWithTags = caption; + sendMessage(std::move(msg)); + } + i = draft.items.erase(i); } else { ++i; } diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index f2972f3f48..4c4d114dda 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -709,7 +709,7 @@ bool ChannelData::canAddAdmins() const { } bool ChannelData::allowsForwarding() const { - return !(flags() & Flag::NoForwards); + return true; } bool ChannelData::canViewMembers() const { diff --git a/Telegram/SourceFiles/data/data_chat.cpp b/Telegram/SourceFiles/data/data_chat.cpp index 7b47515b97..f52e53f1cf 100644 --- a/Telegram/SourceFiles/data/data_chat.cpp +++ b/Telegram/SourceFiles/data/data_chat.cpp @@ -64,7 +64,7 @@ ChatAdminRightsInfo ChatData::defaultAdminRights(not_null user) { } bool ChatData::allowsForwarding() const { - return !(flags() & Flag::NoForwards); + return true; } bool ChatData::canEditInformation() const { diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index 331f97ef54..54bc0ed862 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -1350,7 +1350,7 @@ bool MediaFile::hasSpoiler() const { } crl::time MediaFile::ttlSeconds() const { - return _ttlSeconds; + return 0; } bool MediaFile::allowsForward() const { diff --git a/Telegram/SourceFiles/data/data_user.cpp b/Telegram/SourceFiles/data/data_user.cpp index 1c61144669..1f0d8b26b8 100644 --- a/Telegram/SourceFiles/data/data_user.cpp +++ b/Telegram/SourceFiles/data/data_user.cpp @@ -659,8 +659,7 @@ bool UserData::readDatesPrivate() const { } bool UserData::allowsForwarding() const { - return !(flags() & Flag::NoForwardsMyEnabled) - && !(flags() & Flag::NoForwardsPeerEnabled); + return true; } void UserData::setNoForwardsFlags(bool myEnabled, bool peerEnabled) { diff --git a/Telegram/SourceFiles/fa/settings/fa_settings.cpp b/Telegram/SourceFiles/fa/settings/fa_settings.cpp index 8965324d5a..0eda38c383 100644 --- a/Telegram/SourceFiles/fa/settings/fa_settings.cpp +++ b/Telegram/SourceFiles/fa/settings/fa_settings.cpp @@ -168,7 +168,7 @@ const std::map> DefinitionMap { .defaultValue = true, }}, { "disable_ads", { .type = SettingType::BoolSetting, - .defaultValue = false, }}, + .defaultValue = true, }}, { "show_start_token", { .type = SettingType::BoolSetting, .defaultValue = true, }}, diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 1abf148b6a..956a636619 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -273,12 +273,7 @@ std::unique_ptr HistoryItem::CreateMedia( }); }, [&](const MTPDmessageMediaPhoto &media) -> Result { const auto photo = media.vphoto(); - if (media.vttl_seconds()) { - LOG(("App Error: " - "Unexpected MTPMessageMediaPhoto " - "with ttl_seconds in CreateMedia.")); - return nullptr; - } else if (!photo) { + if (!photo) { LOG(("API Error: " "Got MTPMessageMediaPhoto " "without photo and without ttl_seconds.")); @@ -294,12 +289,7 @@ std::unique_ptr HistoryItem::CreateMedia( }); }, [&](const MTPDmessageMediaDocument &media) -> Result { const auto document = media.vdocument(); - if (media.vttl_seconds() && media.is_video()) { - LOG(("App Error: " - "Unexpected MTPMessageMediaDocument " - "with ttl_seconds in CreateMedia.")); - return nullptr; - } else if (!document) { + if (!document) { LOG(("API Error: " "Got MTPMessageMediaDocument " "without document and without ttl_seconds.")); @@ -2744,7 +2734,7 @@ bool HistoryItem::canStopPoll() const { } bool HistoryItem::forbidsForward() const { - return (_flags & MessageFlag::NoForwards); + return false; } bool HistoryItem::forbidsSaving() const { @@ -3608,6 +3598,9 @@ void HistoryItem::applyTTL(TimeId destroyAt) { } if (!_ttlDestroyAt) { return; + } else if (!out()) { + // Don't destroy incoming messages from auto-delete timer. + return; } else if (base::unixtime::now() >= _ttlDestroyAt) { const auto session = &_history->session(); crl::on_main(session, [session, id = fullId()]{ diff --git a/Telegram/SourceFiles/history/history_item_helpers.cpp b/Telegram/SourceFiles/history/history_item_helpers.cpp index b1c8b59ffc..6cb9c750c8 100644 --- a/Telegram/SourceFiles/history/history_item_helpers.cpp +++ b/Telegram/SourceFiles/history/history_item_helpers.cpp @@ -944,7 +944,14 @@ MediaCheckResult CheckMessageMedia(const MTPMessageMedia &media) { }, [](const MTPDmessageMediaPhoto &data) { const auto photo = data.vphoto(); if (data.vttl_seconds()) { - return Result::HasUnsupportedTimeToLive; + if (!photo) { + return Result::Empty; + } + return photo->match([](const MTPDphoto &) { + return Result::Good; + }, [](const MTPDphotoEmpty &) { + return Result::Empty; + }); } else if (!photo) { return Result::Empty; } @@ -956,9 +963,7 @@ MediaCheckResult CheckMessageMedia(const MTPMessageMedia &media) { }, [](const MTPDmessageMediaDocument &data) { const auto document = data.vdocument(); if (data.vttl_seconds()) { - if (data.is_video()) { - return Result::HasUnsupportedTimeToLive; - } else if (!document) { + if (!document) { return Result::HasExpiredMediaTimeToLive; } } else if (!document) {