diff options
author | fiaxh <git@lightrise.org> | 2019-02-20 01:44:33 +0100 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2019-02-20 01:48:07 +0100 |
commit | 78ec625dbe0912fc166d62b0507942f462569f4f (patch) | |
tree | 8204f4078424b27f7a20d10b647f930804a12ba4 | |
parent | 73cb6eaa49a66b49dbde0a79950110823517b7f5 (diff) | |
download | dino-78ec625dbe0912fc166d62b0507942f462569f4f.tar.gz dino-78ec625dbe0912fc166d62b0507942f462569f4f.zip |
Check for eme tag before adding fallback text for empty-body OMEMO messages
-rw-r--r-- | plugins/omemo/src/trust_manager.vala | 4 | ||||
-rw-r--r-- | xmpp-vala/src/module/xep/0380_explicit_encryption.vala | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/plugins/omemo/src/trust_manager.vala b/plugins/omemo/src/trust_manager.vala index 75c0d809..cd0971f8 100644 --- a/plugins/omemo/src/trust_manager.vala +++ b/plugins/omemo/src/trust_manager.vala @@ -247,7 +247,9 @@ public class TrustManager { StanzaNode? _encrypted = stanza.stanza.get_subnode("encrypted", NS_URI); if (_encrypted == null || MessageFlag.get_flag(stanza) != null || stanza.from == null) return false; StanzaNode encrypted = (!)_encrypted; - if (message.body == null) message.body = "[This message is OMEMO encrypted]"; + if (message.body == null && Xep.ExplicitEncryption.get_encryption_tag(stanza) == NS_URI) { + message.body = "[This message is OMEMO encrypted]"; // TODO temporary + }; if (!Plugin.ensure_context()) return false; MessageFlag flag = new MessageFlag(); stanza.add_flag(flag); diff --git a/xmpp-vala/src/module/xep/0380_explicit_encryption.vala b/xmpp-vala/src/module/xep/0380_explicit_encryption.vala index 710da92d..e956bc43 100644 --- a/xmpp-vala/src/module/xep/0380_explicit_encryption.vala +++ b/xmpp-vala/src/module/xep/0380_explicit_encryption.vala @@ -10,5 +10,13 @@ public static void add_encryption_tag_to_message(MessageStanza message, string n message.stanza.put_node(encryption); } + +public static string? get_encryption_tag(MessageStanza message) { + StanzaNode? encryption_node = message.stanza.get_subnode("encryption", NS_URI); + if (encryption_node != null) { + return encryption_node.get_attribute("namespace", NS_URI); + } + return null; +} } |