aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/src/logic/manager.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-05-21 18:06:25 +0200
committerfiaxh <git@lightrise.org>2019-07-08 18:46:30 +0200
commit06db4d0aa672b234d3336318c8a629b90488be6a (patch)
tree15bae486a0f81a3ad5ca1bc4175e8e31144cb2f0 /plugins/omemo/src/logic/manager.vala
parenta7aa5130f821252c17ffc5725e4240553248ad17 (diff)
downloaddino-06db4d0aa672b234d3336318c8a629b90488be6a.tar.gz
dino-06db4d0aa672b234d3336318c8a629b90488be6a.zip
OMEMO: Rename variables, refactor can_encrypt
Diffstat (limited to 'plugins/omemo/src/logic/manager.vala')
-rw-r--r--plugins/omemo/src/logic/manager.vala26
1 files changed, 12 insertions, 14 deletions
diff --git a/plugins/omemo/src/logic/manager.vala b/plugins/omemo/src/logic/manager.vala
index 0fe4fe50..b8862ab8 100644
--- a/plugins/omemo/src/logic/manager.vala
+++ b/plugins/omemo/src/logic/manager.vala
@@ -358,23 +358,21 @@ public class Manager : StreamInteractionModule, Object {
public bool can_encrypt(Entities.Conversation conversation) {
- XmppStream? stream = stream_interactor.get_stream(conversation.account);
- if (stream == null) return false;
- if (stream_interactor.get_module(MucManager.IDENTITY).is_groupchat(conversation.counterpart, conversation.account)){
- Xep.Muc.Flag? flag = stream.get_flag(Xep.Muc.Flag.IDENTITY);
- if (flag == null) return false;
- if (flag.has_room_feature(conversation.counterpart, Xep.Muc.Feature.NON_ANONYMOUS) && flag.has_room_feature(conversation.counterpart, Xep.Muc.Feature.MEMBERS_ONLY)) {
- foreach(Jid jid in stream_interactor.get_module(MucManager.IDENTITY).get_offline_members(conversation.counterpart, conversation.account)) {
- if (!trust_manager.is_known_address(conversation.account, jid.bare_jid)) {
- debug(@"Can't enable OMEMO for $(conversation.counterpart): missing keys for $(jid.bare_jid)");
- return false;
- }
+ if (stream_interactor.get_module(MucManager.IDENTITY).is_public_room(conversation.account, conversation.counterpart)){
+ debug("Can't enable OMEMO for %s: Room not members-only or non-anonymous", conversation.counterpart.to_string());
+ return false;
+ }
+
+ if (stream_interactor.get_module(MucManager.IDENTITY).is_private_room(conversation.account, conversation.counterpart)){
+ foreach(Jid jid in stream_interactor.get_module(MucManager.IDENTITY).get_offline_members(conversation.counterpart, conversation.account)) {
+ if (!trust_manager.is_known_address(conversation.account, jid.bare_jid)) {
+ debug("Can't enable OMEMO for %s: missing keys for %s", conversation.counterpart.to_string(), jid.bare_jid.to_string());
+ return false;
}
- return true;
- } else {
- return false;
}
+ return true;
}
+
return trust_manager.is_known_address(conversation.account, conversation.counterpart.bare_jid);
}