mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Skip "contact joined" toast if disabled in Settings.
The chats still appear (they are server-side), but skip the toast.
This commit is contained in:
parent
cf76933352
commit
2f5bed2899
5 changed files with 21 additions and 8 deletions
|
@ -341,6 +341,9 @@ enum class MessageFlag : uint32 {
|
||||||
|
|
||||||
// Fake message for some UI element.
|
// Fake message for some UI element.
|
||||||
FakeHistoryItem = (1U << 27),
|
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; }
|
inline constexpr bool is_flag_type(MessageFlag) { return true; }
|
||||||
using MessageFlags = base::flags<MessageFlag>;
|
using MessageFlags = base::flags<MessageFlag>;
|
||||||
|
|
|
@ -459,6 +459,17 @@ bool HistoryItem::isScheduled() const {
|
||||||
&& (_flags & MessageFlag::IsOrWasScheduled);
|
&& (_flags & MessageFlag::IsOrWasScheduled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HistoryItem::skipNotification() const {
|
||||||
|
if (isSilent() && (_flags & MessageFlag::IsContactSignUp)) {
|
||||||
|
return true;
|
||||||
|
} else if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||||
|
if (forwarded->imported) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryItem::destroy() {
|
void HistoryItem::destroy() {
|
||||||
_history->destroyMessage(this);
|
_history->destroyMessage(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,7 @@ public:
|
||||||
[[nodiscard]] bool isAdminLogEntry() const;
|
[[nodiscard]] bool isAdminLogEntry() const;
|
||||||
[[nodiscard]] bool isFromScheduled() const;
|
[[nodiscard]] bool isFromScheduled() const;
|
||||||
[[nodiscard]] bool isScheduled() const;
|
[[nodiscard]] bool isScheduled() const;
|
||||||
|
[[nodiscard]] bool skipNotification() const;
|
||||||
|
|
||||||
void addLogEntryOriginal(
|
void addLogEntryOriginal(
|
||||||
WebPageId localId,
|
WebPageId localId,
|
||||||
|
|
|
@ -554,6 +554,8 @@ void HistoryService::applyAction(const MTPMessageAction &action) {
|
||||||
_flags |= MessageFlag::IsGroupEssential;
|
_flags |= MessageFlag::IsGroupEssential;
|
||||||
}, [&](const MTPDmessageActionChannelMigrateFrom &) {
|
}, [&](const MTPDmessageActionChannelMigrateFrom &) {
|
||||||
_flags |= MessageFlag::IsGroupEssential;
|
_flags |= MessageFlag::IsGroupEssential;
|
||||||
|
}, [&](const MTPDmessageActionContactSignUp &) {
|
||||||
|
_flags |= MessageFlag::IsContactSignUp;
|
||||||
}, [](const auto &) {
|
}, [](const auto &) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,25 +98,21 @@ System::SkipState System::skipNotification(
|
||||||
not_null<HistoryItem*> item) const {
|
not_null<HistoryItem*> item) const {
|
||||||
const auto history = item->history();
|
const auto history = item->history();
|
||||||
const auto notifyBy = item->specialNotificationPeer();
|
const auto notifyBy = item->specialNotificationPeer();
|
||||||
if (App::quitting() || !history->currentNotification()) {
|
if (App::quitting()
|
||||||
|
|| !history->currentNotification()
|
||||||
|
|| item->skipNotification()) {
|
||||||
return { SkipState::Skip };
|
return { SkipState::Skip };
|
||||||
} else if (!Core::App().settings().notifyFromAll()
|
} else if (!Core::App().settings().notifyFromAll()
|
||||||
&& &history->session().account() != &Core::App().domain().active()) {
|
&& &history->session().account() != &Core::App().domain().active()) {
|
||||||
return { SkipState::Skip };
|
return { SkipState::Skip };
|
||||||
}
|
}
|
||||||
const auto scheduled = item->out() && item->isFromScheduled();
|
|
||||||
|
|
||||||
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
|
|
||||||
if (forwarded->imported) {
|
|
||||||
return { SkipState::Skip };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
history->owner().requestNotifySettings(history->peer);
|
history->owner().requestNotifySettings(history->peer);
|
||||||
if (notifyBy) {
|
if (notifyBy) {
|
||||||
history->owner().requestNotifySettings(notifyBy);
|
history->owner().requestNotifySettings(notifyBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto scheduled = item->out() && item->isFromScheduled();
|
||||||
if (history->owner().notifyMuteUnknown(history->peer)) {
|
if (history->owner().notifyMuteUnknown(history->peer)) {
|
||||||
return { SkipState::Unknown, item->isSilent() };
|
return { SkipState::Unknown, item->isSilent() };
|
||||||
} else if (!history->owner().notifyIsMuted(history->peer)) {
|
} else if (!history->owner().notifyIsMuted(history->peer)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue