aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/notifications.vala
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/notifications.vala')
-rw-r--r--main/src/ui/notifications.vala12
1 files changed, 11 insertions, 1 deletions
diff --git a/main/src/ui/notifications.vala b/main/src/ui/notifications.vala
index e5eda271..32e8d7ad 100644
--- a/main/src/ui/notifications.vala
+++ b/main/src/ui/notifications.vala
@@ -31,6 +31,8 @@ public class Notifications : Object {
}
private void on_message_received(Entities.Message message, Conversation conversation) {
+ if (!should_notify_message(message, conversation)) return;
+
if (!notifications.has_key(conversation)) {
notifications[conversation] = new Notify.Notification("", null, null);
notifications[conversation].set_hint("transient", true);
@@ -74,7 +76,7 @@ public class Notifications : Object {
AddConversation.Chat.AddContactDialog dialog = new AddConversation.Chat.AddContactDialog(stream_interactor);
dialog.jid = jid.bare_jid.to_string();
dialog.account = account;
- dialog.show();
+ dialog.present();
}
try {
notification.close();
@@ -90,6 +92,14 @@ public class Notifications : Object {
notification.show();
} catch (Error error) { }
}
+
+ private bool should_notify_message(Entities.Message message, Conversation conversation) {
+ Conversation.NotifySetting notify = conversation.get_notification_setting(stream_interactor);
+ if (notify == Conversation.NotifySetting.OFF) return false;
+ string? nick = stream_interactor.get_module(MucManager.IDENTITY).get_nick(conversation.counterpart, conversation.account);
+ if (notify == Conversation.NotifySetting.HIGHLIGHT && nick != null && !message.body.contains(nick)) return false;
+ return true;
+ }
}
} \ No newline at end of file