Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Telegram/SourceFiles/apiwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>(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;
}
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/data/data_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ bool ChannelData::canAddAdmins() const {
}

bool ChannelData::allowsForwarding() const {
return !(flags() & Flag::NoForwards);
return true;
}

bool ChannelData::canViewMembers() const {
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/data/data_chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ChatAdminRightsInfo ChatData::defaultAdminRights(not_null<UserData*> user) {
}

bool ChatData::allowsForwarding() const {
return !(flags() & Flag::NoForwards);
return true;
}

bool ChatData::canEditInformation() const {
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/data/data_media_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ bool MediaFile::hasSpoiler() const {
}

crl::time MediaFile::ttlSeconds() const {
return _ttlSeconds;
return 0;
}

bool MediaFile::allowsForward() const {
Expand Down
3 changes: 1 addition & 2 deletions Telegram/SourceFiles/data/data_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/fa/settings/fa_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
.defaultValue = true, }},
{ "disable_ads", {
.type = SettingType::BoolSetting,
.defaultValue = false, }},
.defaultValue = true, }},
{ "show_start_token", {
.type = SettingType::BoolSetting,
.defaultValue = true, }},
Expand Down
19 changes: 6 additions & 13 deletions Telegram/SourceFiles/history/history_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,7 @@ std::unique_ptr<Data::Media> 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."));
Expand All @@ -294,12 +289,7 @@ std::unique_ptr<Data::Media> 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."));
Expand Down Expand Up @@ -2744,7 +2734,7 @@ bool HistoryItem::canStopPoll() const {
}

bool HistoryItem::forbidsForward() const {
return (_flags & MessageFlag::NoForwards);
return false;
}

bool HistoryItem::forbidsSaving() const {
Expand Down Expand Up @@ -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()]{
Expand Down
13 changes: 9 additions & 4 deletions Telegram/SourceFiles/history/history_item_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down