From 1c8c6d5f85b40c3cbbe158a58ba709d6e075c30c Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Tue, 9 May 2017 17:46:07 -0700 Subject: [PATCH] Be sure to canonicalize numbers when updating groups // FREEBIE --- .../securesms/jobs/IdentityUpdateJob.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/jobs/IdentityUpdateJob.java b/src/org/thoughtcrime/securesms/jobs/IdentityUpdateJob.java index 3c741e80bb..15895a83b7 100644 --- a/src/org/thoughtcrime/securesms/jobs/IdentityUpdateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/IdentityUpdateJob.java @@ -1,6 +1,7 @@ package org.thoughtcrime.securesms.jobs; import android.content.Context; +import android.util.Log; import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.database.DatabaseFactory; @@ -12,12 +13,16 @@ import org.thoughtcrime.securesms.recipients.RecipientFactory; import org.thoughtcrime.securesms.recipients.Recipients; import org.thoughtcrime.securesms.sms.IncomingIdentityUpdateMessage; import org.thoughtcrime.securesms.sms.IncomingTextMessage; +import org.thoughtcrime.securesms.util.Util; import org.whispersystems.jobqueue.JobParameters; import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.signalservice.api.messages.SignalServiceGroup; +import org.whispersystems.signalservice.api.util.InvalidNumberException; public class IdentityUpdateJob extends MasterSecretJob { + private static final String TAG = IdentityUpdateJob.class.getSimpleName(); + private final long recipientId; public IdentityUpdateJob(Context context, long recipientId) { @@ -29,16 +34,23 @@ public class IdentityUpdateJob extends MasterSecretJob { } @Override - public void onRun(MasterSecret masterSecret) throws Exception { + public void onRun(MasterSecret masterSecret) { Recipient recipient = RecipientFactory.getRecipientForId(context, recipientId, true); Recipients recipients = RecipientFactory.getRecipientsFor(context, recipient, true); - String number = recipient.getNumber(); long time = System.currentTimeMillis(); SmsDatabase smsDatabase = DatabaseFactory.getSmsDatabase(context); ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context); GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context); GroupDatabase.Reader reader = groupDatabase.getGroups(); + String number = recipient.getNumber(); + + try { + number = Util.canonicalizeNumber(context, number); + } catch (InvalidNumberException e) { + Log.w(TAG, e); + } + GroupDatabase.GroupRecord groupRecord; while ((groupRecord = reader.getNext()) != null) {