diff --git a/Telegram/SourceFiles/data/data_types.h b/Telegram/SourceFiles/data/data_types.h index 680ce3aa8..dc257df8e 100644 --- a/Telegram/SourceFiles/data/data_types.h +++ b/Telegram/SourceFiles/data/data_types.h @@ -341,6 +341,9 @@ enum class MessageFlag : uint32 { // Fake message for some UI element. FakeHistoryItem = (1U << 27), + + // Contact sign-up message, notification should be skipped for Silent. + IsContactSignUp = (1U << 28), }; inline constexpr bool is_flag_type(MessageFlag) { return true; } using MessageFlags = base::flags; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 553bf54aa..b37aad5ad 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -459,6 +459,17 @@ bool HistoryItem::isScheduled() const { && (_flags & MessageFlag::IsOrWasScheduled); } +bool HistoryItem::skipNotification() const { + if (isSilent() && (_flags & MessageFlag::IsContactSignUp)) { + return true; + } else if (const auto forwarded = Get()) { + if (forwarded->imported) { + return true; + } + } + return false; +} + void HistoryItem::destroy() { _history->destroyMessage(this); } diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 813c2e734..feaa262de 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -109,6 +109,7 @@ public: [[nodiscard]] bool isAdminLogEntry() const; [[nodiscard]] bool isFromScheduled() const; [[nodiscard]] bool isScheduled() const; + [[nodiscard]] bool skipNotification() const; void addLogEntryOriginal( WebPageId localId, diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index 8775b3c02..f5eed00d6 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -554,6 +554,8 @@ void HistoryService::applyAction(const MTPMessageAction &action) { _flags |= MessageFlag::IsGroupEssential; }, [&](const MTPDmessageActionChannelMigrateFrom &) { _flags |= MessageFlag::IsGroupEssential; + }, [&](const MTPDmessageActionContactSignUp &) { + _flags |= MessageFlag::IsContactSignUp; }, [](const auto &) { }); } diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index d5f54c917..7a720bfca 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -98,25 +98,21 @@ System::SkipState System::skipNotification( not_null item) const { const auto history = item->history(); const auto notifyBy = item->specialNotificationPeer(); - if (App::quitting() || !history->currentNotification()) { + if (App::quitting() + || !history->currentNotification() + || item->skipNotification()) { return { SkipState::Skip }; } else if (!Core::App().settings().notifyFromAll() && &history->session().account() != &Core::App().domain().active()) { return { SkipState::Skip }; } - const auto scheduled = item->out() && item->isFromScheduled(); - - if (const auto forwarded = item->Get()) { - if (forwarded->imported) { - return { SkipState::Skip }; - } - } history->owner().requestNotifySettings(history->peer); if (notifyBy) { history->owner().requestNotifySettings(notifyBy); } + const auto scheduled = item->out() && item->isFromScheduled(); if (history->owner().notifyMuteUnknown(history->peer)) { return { SkipState::Unknown, item->isSilent() }; } else if (!history->owner().notifyIsMuted(history->peer)) {