From b75442a10e69d54bb689e41b54bd486377854870 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 7 Dec 2018 20:15:58 +0400 Subject: [PATCH] No warning from verified peers. --- Telegram/SourceFiles/data/data_document.cpp | 25 ++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index 5b93e7ee7a..8c964ec60a 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -66,9 +66,18 @@ QString JoinStringList(const QStringList &list, const QString &separator) { return result; } -void LaunchWithWarning(const QString &name) { - if (!Data::IsExecutableName(name) - || !Auth().settings().exeLaunchWarning()) { +void LaunchWithWarning(const QString &name, HistoryItem *item) { + const auto warn = [&] { + if (!Data::IsExecutableName(name)) { + return false; + } else if (!Auth().settings().exeLaunchWarning()) { + return false; + } else if (item && item->history()->peer->isVerified()) { + return false; + } + return true; + }(); + if (!warn) { File::Launch(name); return; } @@ -359,14 +368,14 @@ void DocumentOpenClickHandler::Open( Messenger::Instance().showDocument(data, context); } } else { - LaunchWithWarning(location.name()); + LaunchWithWarning(location.name(), context); } location.accessDisable(); } else { - LaunchWithWarning(location.name()); + LaunchWithWarning(location.name(), context); } } else { - LaunchWithWarning(location.name()); + LaunchWithWarning(location.name(), context); } return; } @@ -735,11 +744,11 @@ void DocumentData::performActionOnLoad() { if (showImage && QImageReader(loc.name()).canRead()) { Messenger::Instance().showDocument(this, item); } else { - LaunchWithWarning(already); + LaunchWithWarning(already, item); } loc.accessDisable(); } else { - LaunchWithWarning(already); + LaunchWithWarning(already, item); } } }