mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Slight cleanup for ConfirmIdentityDialog change.
Closes #3225 // FREEBIE
This commit is contained in:
parent
72bd6d5844
commit
ec60c24849
@ -55,6 +55,7 @@ import org.thoughtcrime.securesms.mms.Slide;
|
|||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.DateUtils;
|
import org.thoughtcrime.securesms.util.DateUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -369,22 +370,17 @@ public class ConversationItem extends LinearLayout {
|
|||||||
contactPhoto.setAvatar(recipient, true);
|
contactPhoto.setAvatar(recipient, true);
|
||||||
contactPhoto.setVisibility(View.VISIBLE);
|
contactPhoto.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IdentityKeyMismatch getKeyMismatch(final MessageRecord record) {
|
|
||||||
if (record.isIdentityMismatchFailure()) {
|
|
||||||
for (final IdentityKeyMismatch mismatch : record.getIdentityKeyMismatches()) {
|
|
||||||
if (mismatch.getRecipientId() == record.getIndividualRecipient().getRecipientId()) {
|
|
||||||
return mismatch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Event handlers
|
/// Event handlers
|
||||||
|
|
||||||
private void handleKeyExchangeClicked() {
|
private void handleApproveIdentity() {
|
||||||
new ConfirmIdentityDialog(context, masterSecret, messageRecord, getKeyMismatch(messageRecord)).show();
|
List<IdentityKeyMismatch> mismatches = messageRecord.getIdentityKeyMismatches();
|
||||||
|
|
||||||
|
if (mismatches.size() != 1) {
|
||||||
|
throw new AssertionError("Identity mismatch count: " + mismatches.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
new ConfirmIdentityDialog(context, masterSecret, messageRecord, mismatches.get(0)).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ThumbnailClickListener implements ThumbnailView.ThumbnailClickListener {
|
private class ThumbnailClickListener implements ThumbnailView.ThumbnailClickListener {
|
||||||
@ -462,12 +458,8 @@ public class ConversationItem extends LinearLayout {
|
|||||||
intent.putExtra(MessageDetailsActivity.TYPE_EXTRA, messageRecord.isMms() ? MmsSmsDatabase.MMS_TRANSPORT : MmsSmsDatabase.SMS_TRANSPORT);
|
intent.putExtra(MessageDetailsActivity.TYPE_EXTRA, messageRecord.isMms() ? MmsSmsDatabase.MMS_TRANSPORT : MmsSmsDatabase.SMS_TRANSPORT);
|
||||||
intent.putExtra(MessageDetailsActivity.IS_PUSH_GROUP_EXTRA, groupThread && pushDestination);
|
intent.putExtra(MessageDetailsActivity.IS_PUSH_GROUP_EXTRA, groupThread && pushDestination);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
} else if (messageRecord.isKeyExchange() &&
|
} else if (!messageRecord.isOutgoing() && messageRecord.isIdentityMismatchFailure()) {
|
||||||
!messageRecord.isOutgoing() &&
|
handleApproveIdentity();
|
||||||
!messageRecord.isProcessedKeyExchange() &&
|
|
||||||
!messageRecord.isStaleKeyExchange())
|
|
||||||
{
|
|
||||||
handleKeyExchangeClicked();
|
|
||||||
} else if (messageRecord.isPendingInsecureSmsFallback()) {
|
} else if (messageRecord.isPendingInsecureSmsFallback()) {
|
||||||
handleMessageApproval();
|
handleMessageApproval();
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,27 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn
|
|||||||
|
|
||||||
protected abstract String getTableName();
|
protected abstract String getTableName();
|
||||||
|
|
||||||
|
public void setMismatchedIdentity(long messageId, final long recipientId, final IdentityKey identityKey) {
|
||||||
|
List<IdentityKeyMismatch> items = new ArrayList<IdentityKeyMismatch>() {{
|
||||||
|
add(new IdentityKeyMismatch(recipientId, identityKey));
|
||||||
|
}};
|
||||||
|
|
||||||
|
IdentityKeyMismatchList document = new IdentityKeyMismatchList(items);
|
||||||
|
|
||||||
|
SQLiteDatabase database = databaseHelper.getWritableDatabase();
|
||||||
|
database.beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
setDocument(database, messageId, MISMATCHED_IDENTITIES, document);
|
||||||
|
|
||||||
|
database.setTransactionSuccessful();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
Log.w(TAG, ioe);
|
||||||
|
} finally {
|
||||||
|
database.endTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addMismatchedIdentity(long messageId, long recipientId, IdentityKey identityKey) {
|
public void addMismatchedIdentity(long messageId, long recipientId, IdentityKey identityKey) {
|
||||||
try {
|
try {
|
||||||
addToDocument(messageId, MISMATCHED_IDENTITIES,
|
addToDocument(messageId, MISMATCHED_IDENTITIES,
|
||||||
@ -133,7 +154,9 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return clazz.newInstance();
|
return clazz.newInstance();
|
||||||
} catch (InstantiationException | IllegalAccessException e) {
|
} catch (InstantiationException e) {
|
||||||
|
throw new AssertionError(e);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,12 +292,12 @@ public class PushDecryptJob extends MasterSecretJob {
|
|||||||
IncomingPreKeyBundleMessage bundleMessage = new IncomingPreKeyBundleMessage(textMessage, encoded);
|
IncomingPreKeyBundleMessage bundleMessage = new IncomingPreKeyBundleMessage(textMessage, encoded);
|
||||||
Pair<Long, Long> messageAndThreadId = database.insertMessageInbox(masterSecret, bundleMessage);
|
Pair<Long, Long> messageAndThreadId = database.insertMessageInbox(masterSecret, bundleMessage);
|
||||||
|
|
||||||
database.addMismatchedIdentity(messageAndThreadId.first, recipientId, identityKey);
|
database.setMismatchedIdentity(messageAndThreadId.first, recipientId, identityKey);
|
||||||
MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
|
MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
|
||||||
} else {
|
} else {
|
||||||
database.updateMessageBody(masterSecret, smsMessageId.get(), encoded);
|
database.updateMessageBody(masterSecret, smsMessageId.get(), encoded);
|
||||||
database.markAsPreKeyBundle(smsMessageId.get());
|
database.markAsPreKeyBundle(smsMessageId.get());
|
||||||
database.addMismatchedIdentity(smsMessageId.get(), recipientId, identityKey);
|
database.setMismatchedIdentity(smsMessageId.get(), recipientId, identityKey);
|
||||||
}
|
}
|
||||||
} catch (InvalidMessageException | InvalidVersionException e) {
|
} catch (InvalidMessageException | InvalidVersionException e) {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user