summaryrefslogtreecommitdiff
path: root/src/notifications/notifications.cpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2023-03-16 21:15:56 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2023-03-16 21:15:56 -0400
commit02f7bfefe3185a38f8935b31c68857b986d709ac (patch)
tree37e481cd52e13bf864ac88dca5a6943cc7ac4585 /src/notifications/notifications.cpp
parentb83bf2a622ecfb667cc89909ebae9180ed5ac117 (diff)
downloadabaddon-portaudio-02f7bfefe3185a38f8935b31c68857b986d709ac.tar.gz
abaddon-portaudio-02f7bfefe3185a38f8935b31c68857b986d709ac.zip
withdraw notifications on channel open
Diffstat (limited to 'src/notifications/notifications.cpp')
-rw-r--r--src/notifications/notifications.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/notifications/notifications.cpp b/src/notifications/notifications.cpp
index fc7a2d6..5b834ce 100644
--- a/src/notifications/notifications.cpp
+++ b/src/notifications/notifications.cpp
@@ -99,12 +99,23 @@ void Notifications::CheckMessage(const Message &message) {
// notify messages in DMs
const auto channel = discord.GetChannel(message.ChannelID);
if (channel->IsDM()) {
+ m_chan_notifications[message.ChannelID].push_back(message.ID);
NotifyMessageDM(message);
} else if (CheckGuildMessage(message)) {
+ m_chan_notifications[message.ChannelID].push_back(message.ID);
NotifyMessageGuild(message);
}
}
+void Notifications::WithdrawChannel(Snowflake channel_id) {
+ if (auto it = m_chan_notifications.find(channel_id); it != m_chan_notifications.end()) {
+ for (const auto notification_id : it->second) {
+ m_notifier.Withdraw(std::to_string(notification_id));
+ }
+ it->second.clear();
+ }
+}
+
Glib::ustring Sanitize(const Message &message) {
auto buf = Gtk::TextBuffer::create();
Gtk::TextBuffer::iterator begin, end;
@@ -123,7 +134,7 @@ void Notifications::NotifyMessageDM(const Message &message) {
const auto body = Sanitize(message);
Abaddon::Get().GetImageManager().GetCache().GetFileFromURL(message.Author.GetAvatarURL("png", "64"), [=](const std::string &path) {
- m_notifier.Notify(title, body, default_action, path);
+ m_notifier.Notify(std::to_string(message.ID), title, body, default_action, path);
});
}
@@ -146,7 +157,7 @@ void Notifications::NotifyMessageGuild(const Message &message) {
}
const auto body = Sanitize(message);
Abaddon::Get().GetImageManager().GetCache().GetFileFromURL(message.Author.GetAvatarURL("png", "64"), [=](const std::string &path) {
- m_notifier.Notify(title, body, default_action, path);
+ m_notifier.Notify(std::to_string(message.ID), title, body, default_action, path);
});
}