improved error messages on missing omemo keys

This commit is contained in:
Daniel Gultsch 2017-08-21 14:08:20 +02:00
parent 8c3586f6a0
commit e0fa820436
2 changed files with 24 additions and 2 deletions

View File

@ -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<Jid> contactJids){
for(Jid jid : contactJids) {
if (!mAccount.getRoster().getContact(jid).mutualPresenceSubscription()) {
return true;
}
}
return false;
}
private boolean foreignActuallyHasKeys() {
synchronized (this.foreignKeysToTrust) {
for (Map.Entry<Jid, Map<String, Boolean>> entry : foreignKeysToTrust.entrySet()) {

View File

@ -434,6 +434,7 @@
<string name="clear_other_devices">Clear devices</string>
<string name="clear_other_devices_desc">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.</string>
<string name="error_no_keys_to_trust_server_error">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.</string>
<string name="error_no_keys_to_trust_presence">There are no usable keys available for this contact.\nMake sure you have mutual presence subscription.</string>
<string name="error_no_keys_to_trust">There are no usable keys available for this contact. If you have purged any of their keys, they need to generate new ones.</string>
<string name="error_trustkeys_title">Error</string>
<string name="fetching_history_from_server">Fetching history from server</string>