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 | |
parent | fbd70ceaac5ebbddfa21a580c61165bf5b861303 (diff) | |
download | dino-13d3d2aca6f5975bbf16ba56b7cd0c4e2008e936.tar.gz dino-13d3d2aca6f5975bbf16ba56b7cd0c4e2008e936.zip |
Handle unknown own MUC jid better
Diffstat (limited to 'libdino/src/service')
-rw-r--r-- | libdino/src/service/message_correction.vala | 11 | ||||
-rw-r--r-- | libdino/src/service/notification_events.vala | 15 |
2 files changed, 17 insertions, 9 deletions
diff --git a/libdino/src/service/message_correction.vala b/libdino/src/service/message_correction.vala index e38fd251..eb0b9287 100644 --- a/libdino/src/service/message_correction.vala +++ b/libdino/src/service/message_correction.vala @@ -68,17 +68,22 @@ public class MessageCorrection : StreamInteractionModule, MessageListener { public bool is_own_correction_allowed(Conversation conversation, Message message) { string stanza_id = message.edit_to ?? message.stanza_id; - Jid own_jid = conversation.account.full_jid; - if (conversation.type_ == Conversation.Type.GROUPCHAT) { + Jid? own_jid = null; + if (conversation.type_ == Conversation.Type.CHAT) { + own_jid = conversation.account.full_jid; + } else if (conversation.type_ == Conversation.Type.GROUPCHAT) { own_jid = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account); } + + if (own_jid == null) return false; + return last_messages.has_key(conversation) && last_messages[conversation].has_key(own_jid) && last_messages[conversation][own_jid].stanza_id == stanza_id; } private void check_add_correction_node(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) { - if (message.stanza_id in outstanding_correction_nodes) { + if (outstanding_correction_nodes.has_key(message.stanza_id)) { LastMessageCorrection.set_replace_id(message_stanza, outstanding_correction_nodes[message.stanza_id]); outstanding_correction_nodes.unset(message.stanza_id); } else { 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; } |