mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Improve and centralize e164 utils.
This commit is contained in:
@@ -62,10 +62,12 @@ public class AvatarMigrationJob extends MigrationJob {
|
||||
for (File file : files) {
|
||||
try {
|
||||
if (isValidFileName(file.getName())) {
|
||||
Recipient recipient = Recipient.external(context, file.getName());
|
||||
Recipient recipient = Recipient.external(file.getName());
|
||||
byte[] data = StreamUtil.readFully(new FileInputStream(file));
|
||||
|
||||
AvatarHelper.setAvatar(context, recipient.getId(), new ByteArrayInputStream(data));
|
||||
if (recipient != null) {
|
||||
AvatarHelper.setAvatar(context, recipient.getId(), new ByteArrayInputStream(data));
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "Invalid file name! Can't migrate this file. It'll just get deleted.");
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ import org.thoughtcrime.securesms.database.RecipientTable.Companion.PNI_COLUMN
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.Companion.TABLE_NAME
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.util.SignalE164Util
|
||||
|
||||
/**
|
||||
* Through testing, we've discovered that some badly-formatted e164's wound up in the e164 column of the recipient table.
|
||||
@@ -89,7 +89,7 @@ internal class BadE164MigrationJob(
|
||||
continue
|
||||
}
|
||||
|
||||
val formattedNumber = PhoneNumberFormatter.get(context).formatOrNull(entry.e164)
|
||||
val formattedNumber = SignalE164Util.formatAsE164(entry.e164)
|
||||
if (formattedNumber == null) {
|
||||
Log.w(TAG, "We have encountered an e164-only recipient, with messages, whose value characters are all valid, but still remains completely unparsable.")
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user