diff options
author | fiaxh <git@lightrise.org> | 2020-04-14 16:28:36 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2020-04-14 16:33:53 +0200 |
commit | 13d3d2aca6f5975bbf16ba56b7cd0c4e2008e936 (patch) | |
tree | a599f27e9cba3b440bfea3ade052bee9842daa14 /libdino/src/service/notification_events.vala | |
parent | fbd70ceaac5ebbddfa21a580c61165bf5b861303 (diff) | |
download | dino-13d3d2aca6f5975bbf16ba56b7cd0c4e2008e936.tar.gz dino-13d3d2aca6f5975bbf16ba56b7cd0c4e2008e936.zip |
Handle unknown own MUC jid better
Diffstat (limited to 'libdino/src/service/notification_events.vala')
-rw-r--r-- | libdino/src/service/notification_events.vala | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libdino/src/service/notification_events.vala b/libdino/src/service/notification_events.vala index dca81af8..54206e99 100644 --- a/libdino/src/service/notification_events.vala +++ b/libdino/src/service/notification_events.vala @@ -48,6 +48,9 @@ public class NotificationEvents : StreamInteractionModule, Object { private bool should_notify(ContentItem content_item, Conversation conversation) { Conversation.NotifySetting notify = conversation.get_notification_setting(stream_interactor); + + if (notify == Conversation.NotifySetting.OFF) return false; + switch (content_item.type_) { case MessageItem.TYPE: Message message = (content_item as MessageItem).message; @@ -60,13 +63,13 @@ public class NotificationEvents : StreamInteractionModule, Object { if (file_transfer.direction == FileTransfer.DIRECTION_SENT) return false; break; } - if (notify == Conversation.NotifySetting.OFF) return false; - Jid? nick = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account); - if (content_item.type_ == MessageItem.TYPE) { + + if (content_item.type_ == MessageItem.TYPE && notify == Conversation.NotifySetting.HIGHLIGHT) { + Jid? nick = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account); + if (nick == null) return false; + Entities.Message message = (content_item as MessageItem).message; - if (notify == Conversation.NotifySetting.HIGHLIGHT && nick != null) { - return Regex.match_simple("\\b" + Regex.escape_string(nick.resourcepart) + "\\b", message.body, RegexCompileFlags.CASELESS); - } + return Regex.match_simple("\\b" + Regex.escape_string(nick.resourcepart) + "\\b", message.body, RegexCompileFlags.CASELESS); } return true; } |