From e0fa82043688e390f8be2ef1c1e2218af3f9be9f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 21 Aug 2017 14:08:20 +0200 Subject: [PATCH] improved error messages on missing omemo keys --- .../conversations/ui/TrustKeysActivity.java | 25 +++++++++++++++++-- src/main/res/values/strings.xml | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java index 65194e004..c14e0961c 100644 --- a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java @@ -228,7 +228,15 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat } if (fingerprints.size() == 0) { informNoKeys.setVisibility(View.VISIBLE); - informNoKeys.setText(getString(R.string.no_keys_just_confirm,mAccount.getRoster().getContact(jid).getDisplayName())); + if (hasNoOtherTrustedKeys(jid)) { + if (!mAccount.getRoster().getContact(jid).mutualPresenceSubscription()) { + informNoKeys.setText(R.string.error_no_keys_to_trust_presence); + } else { + informNoKeys.setText(R.string.error_no_keys_to_trust_server_error); + } + } else { + informNoKeys.setText(getString(R.string.no_keys_just_confirm, mAccount.getRoster().getContact(jid).getDisplayName())); + } } else { informNoKeys.setVisibility(View.GONE); } @@ -251,7 +259,11 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat keyErrorMessageCard.setVisibility(View.VISIBLE); if (lastFetchReport == AxolotlService.FetchStatus.ERROR || mAccount.getAxolotlService().fetchMapHasErrors(contactJids)) { - keyErrorMessage.setText(R.string.error_no_keys_to_trust_server_error); + if (anyWithoutMutualPresenceSubscription(contactJids)) { + keyErrorMessage.setText(R.string.error_no_keys_to_trust_presence); + } else { + keyErrorMessage.setText(R.string.error_no_keys_to_trust_server_error); + } } else { keyErrorMessage.setText(R.string.error_no_keys_to_trust); } @@ -265,6 +277,15 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat } } + private boolean anyWithoutMutualPresenceSubscription(List contactJids){ + for(Jid jid : contactJids) { + if (!mAccount.getRoster().getContact(jid).mutualPresenceSubscription()) { + return true; + } + } + return false; + } + private boolean foreignActuallyHasKeys() { synchronized (this.foreignKeysToTrust) { for (Map.Entry> entry : foreignKeysToTrust.entrySet()) { diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 00f18e14b..37f2ae960 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -434,6 +434,7 @@ Clear devices Are you sure you want to clear all other devices from the OMEMO announcement? The next time your devices connect, they will reannounce themselves, but they might not receive messages sent in the meantime. There are no usable keys available for this contact.\nFetching new keys from the server has been unsuccessful. Maybe there is something wrong with your contacts server. + There are no usable keys available for this contact.\nMake sure you have mutual presence subscription. There are no usable keys available for this contact. If you have purged any of their keys, they need to generate new ones. Error Fetching history from server