diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-09-26 21:32:06 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-09-26 21:32:06 +0200 |
commit | 0e0e93a312fa3e091c4113dc4ef9b8d7b521f034 (patch) | |
tree | ac1d060c345cee9401dd7b5e4fd88bbf3b5acae7 | |
parent | d19ee1daad39618740564a5f90a7caa091abc334 (diff) |
check omemo keys when attachments are commit instead of before
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 460695779..d326058e7 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -131,7 +131,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public static final int REQUEST_DECRYPT_PGP = 0x0202; public static final int REQUEST_ENCRYPT_MESSAGE = 0x0207; public static final int REQUEST_TRUST_KEYS_TEXT = 0x0208; - public static final int REQUEST_TRUST_KEYS_MENU = 0x0209; + public static final int REQUEST_TRUST_KEYS_ATTACHMENTS = 0x0209; public static final int REQUEST_START_DOWNLOAD = 0x0210; public static final int REQUEST_ADD_EDITOR_CONTENT = 0x0211; public static final int ATTACHMENT_CHOICE = 0x0300; @@ -927,10 +927,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } protected boolean trustKeysIfNeeded(int requestCode) { - return trustKeysIfNeeded(requestCode, ATTACHMENT_CHOICE_INVALID); - } - - protected boolean trustKeysIfNeeded(int requestCode, int attachmentChoice) { AxolotlService axolotlService = conversation.getAccount().getAxolotlService(); final List<Jid> targets = axolotlService.getCryptoTargets(conversation); boolean hasUnaccepted = !conversation.getAcceptedCryptoTargets().containsAll(targets); @@ -948,7 +944,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } intent.putExtra("contacts", contacts); intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toString()); - intent.putExtra("choice", attachmentChoice); intent.putExtra("conversation", conversation.getUuid()); startActivityForResult(intent, requestCode); return true; @@ -998,9 +993,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke Message message = new Message(conversation, body, conversation.getNextEncryption()); sendMessage(message); break; - case REQUEST_TRUST_KEYS_MENU: - int choice = data.getIntExtra("choice", ATTACHMENT_CHOICE_INVALID); - selectPresenceToAttachFile(choice); + case REQUEST_TRUST_KEYS_ATTACHMENTS: + commitAttachments(); break; case ATTACHMENT_CHOICE_CHOOSE_IMAGE: final List<Attachment> imageUris = Attachment.extractAttachments(getActivity(), data, Attachment.Type.IMAGE); @@ -1044,6 +1038,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } private void commitAttachments() { + if (conversation.getNextEncryption() == Message.ENCRYPTION_AXOLOTL && trustKeysIfNeeded(REQUEST_TRUST_KEYS_ATTACHMENTS)) { + return; + } final List<Attachment> attachments = mediaPreviewAdapter.getAttachments(); final PresenceSelector.OnPresenceSelected callback = () -> { for (Iterator<Attachment> i = attachments.iterator(); i.hasNext(); i.remove()) { @@ -1637,9 +1634,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke activity.showInstallPgpDialog(); } } else { - if (encryption != Message.ENCRYPTION_AXOLOTL || !trustKeysIfNeeded(REQUEST_TRUST_KEYS_MENU, attachmentChoice)) { - selectPresenceToAttachFile(attachmentChoice); - } + selectPresenceToAttachFile(attachmentChoice); } } |