Merge tag 'v7.39.5' into molly-7.39

This commit is contained in:
Oscar Mira 2025-04-16 20:41:47 +02:00
commit 334866499b
No known key found for this signature in database
GPG key ID: B371B98C5DC32237
7 changed files with 108 additions and 4 deletions

View file

@ -9,8 +9,8 @@ plugins {
}
val canonicalVersionCode = 1535
val canonicalVersionName = "7.39.4"
val currentHotfixVersion = 0
val canonicalVersionName = "7.39.5"
val currentHotfixVersion = 1
val maxHotfixVersions = 100
val mollyRevision = 1

View file

@ -265,7 +265,7 @@ class ChangeNumberRepository(
SignalStore.misc.setPendingChangeNumberMetadata(metadata)
withContext(Dispatchers.IO) {
result = SignalNetwork.account.changeNumber(request)
result = accountManager.registrationApi.changeNumber(request)
}
val possibleError = result.getCause() as? MismatchedDevicesException

View file

@ -61,6 +61,7 @@ import org.thoughtcrime.securesms.migrations.DuplicateE164MigrationJob;
import org.thoughtcrime.securesms.migrations.E164FormattingMigrationJob;
import org.thoughtcrime.securesms.migrations.EmojiDownloadMigrationJob;
import org.thoughtcrime.securesms.migrations.EmojiSearchIndexCheckMigrationJob;
import org.thoughtcrime.securesms.migrations.FixChangeNumberErrorMigrationJob;
import org.thoughtcrime.securesms.migrations.GooglePlayBillingPurchaseTokenMigrationJob;
import org.thoughtcrime.securesms.migrations.IdentityTableCleanupMigrationJob;
import org.thoughtcrime.securesms.migrations.MigrationCompleteJob;
@ -292,6 +293,7 @@ public final class JobManagerFactories {
put(E164FormattingMigrationJob.KEY, new E164FormattingMigrationJob.Factory());
put(EmojiDownloadMigrationJob.KEY, new EmojiDownloadMigrationJob.Factory());
put(EmojiSearchIndexCheckMigrationJob.KEY, new EmojiSearchIndexCheckMigrationJob.Factory());
put(FixChangeNumberErrorMigrationJob.KEY, new FixChangeNumberErrorMigrationJob.Factory());
put(GooglePlayBillingPurchaseTokenMigrationJob.KEY, new GooglePlayBillingPurchaseTokenMigrationJob.Factory());
put(IdentityTableCleanupMigrationJob.KEY, new IdentityTableCleanupMigrationJob.Factory());
put("LegacyMigrationJob", new FailingJob.Factory());

View file

@ -165,9 +165,11 @@ public class ApplicationMigrations {
static final int AVATAR_COLOR_MIGRATION_JOB = 132;
static final int DUPLICATE_E164_FIX_2 = 133;
static final int E164_FORMATTING = 134;
// Need to skip because a 135 exists in 7.40, which went to beta users before this
static final int FIX_CHANGE_NUMBER_ERROR = 136;
}
public static final int CURRENT_VERSION = 134;
public static final int CURRENT_VERSION = 136;
/**
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
@ -750,6 +752,10 @@ public class ApplicationMigrations {
jobs.put(Version.E164_FORMATTING, new E164FormattingMigrationJob());
}
if (lastSeenVersion < Version.FIX_CHANGE_NUMBER_ERROR) {
jobs.put(Version.FIX_CHANGE_NUMBER_ERROR, new FixChangeNumberErrorMigrationJob());
}
return jobs;
}

View file

@ -0,0 +1,73 @@
package org.thoughtcrime.securesms.migrations
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.components.settings.app.changenumber.ChangeNumberRepository
import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.net.SignalNetwork
import org.whispersystems.signalservice.api.NetworkResult
import org.whispersystems.signalservice.api.push.ServiceId
import org.whispersystems.signalservice.internal.push.WhoAmIResponse
import java.io.IOException
/**
* There was a server error during change number where a number was changed but gave back a 409 response.
* We need devices to re-fetch their E164+PNI's, save them, and then get prekeys.
*/
internal class FixChangeNumberErrorMigrationJob(
parameters: Parameters = Parameters.Builder().build()
) : MigrationJob(parameters) {
companion object {
const val KEY = "FixChangeNumberErrorMigrationJob"
private val TAG = Log.tag(FixChangeNumberErrorMigrationJob::class)
}
override fun getFactoryKey(): String = KEY
override fun isUiBlocking(): Boolean = false
override fun performMigration() {
if (!SignalStore.account.isRegistered) {
Log.i(TAG, "Not registered, skipping.")
return
}
val pendingChangeNumberMetadata = SignalStore.misc.pendingChangeNumberMetadata
if (pendingChangeNumberMetadata == null) {
Log.i(TAG, "No pending change number metadata, skipping.")
return
}
if (pendingChangeNumberMetadata.previousPni != SignalStore.account.pni?.toByteString()) {
Log.i(TAG, "Pending change number operation isn't for our current PNI, skipping.")
return
}
when (val result = SignalNetwork.account.whoAmI()) {
is NetworkResult.Success<WhoAmIResponse> -> {
val pni = result.result.pni?.let { ServiceId.PNI.parseOrNull(it) } ?: return
if (result.result.number != SignalStore.account.e164 || pni != SignalStore.account.pni) {
Log.w(TAG, "Detected a number or PNI mismatch! Fixing...")
ChangeNumberRepository().changeLocalNumber(result.result.number, pni)
Log.w(TAG, "Done!")
} else {
Log.i(TAG, "No number or PNI mismatch detected.")
return
}
}
is NetworkResult.ApplicationError -> throw result.throwable
is NetworkResult.NetworkError -> throw result.exception
is NetworkResult.StatusCodeError -> throw result.exception
}
}
override fun shouldRetry(e: Exception): Boolean = e is IOException
class Factory : Job.Factory<FixChangeNumberErrorMigrationJob> {
override fun create(parameters: Parameters, serializedData: ByteArray?): FixChangeNumberErrorMigrationJob {
return FixChangeNumberErrorMigrationJob(parameters)
}
}
}

View file

@ -7,6 +7,7 @@ package org.whispersystems.signalservice.api.registration
import org.whispersystems.signalservice.api.NetworkResult
import org.whispersystems.signalservice.api.account.AccountAttributes
import org.whispersystems.signalservice.api.account.ChangePhoneNumberRequest
import org.whispersystems.signalservice.api.account.PreKeyCollection
import org.whispersystems.signalservice.api.provisioning.RestoreMethod
import org.whispersystems.signalservice.internal.push.BackupV2AuthCheckResponse
@ -133,4 +134,15 @@ class RegistrationApi(
pushServiceSocket.setRestoreMethodChosen(token, RestoreMethodBody(method = method))
}
}
/**
* Changes the phone number that an account is associated with.
*
* `PUT /v2/accounts/number`
*/
fun changeNumber(requestBody: ChangePhoneNumberRequest): NetworkResult<VerifyAccountResponse> {
return NetworkResult.fromFetch {
pushServiceSocket.changeNumber(requestBody)
}
}
}

View file

@ -29,6 +29,7 @@ import org.signal.storageservice.protos.groups.GroupResponse;
import org.signal.storageservice.protos.groups.Member;
import org.whispersystems.signalservice.api.NetworkResult;
import org.whispersystems.signalservice.api.account.AccountAttributes;
import org.whispersystems.signalservice.api.account.ChangePhoneNumberRequest;
import org.whispersystems.signalservice.api.account.PreKeyCollection;
import org.whispersystems.signalservice.api.crypto.SealedSenderAccess;
import org.whispersystems.signalservice.api.groupsv2.GroupsV2AuthorizationString;
@ -413,6 +414,16 @@ public class PushServiceSocket {
if (responseCode == 409) throw new MissingCapabilitiesException();
};
public VerifyAccountResponse changeNumber(@Nonnull ChangePhoneNumberRequest changePhoneNumberRequest)
throws IOException
{
String requestBody = JsonUtil.toJson(changePhoneNumberRequest);
String responseBody = makeServiceRequest("/v2/accounts/number", "PUT", requestBody);
return JsonUtil.fromJson(responseBody, VerifyAccountResponse.class);
}
public void setRestoreMethodChosen(@Nonnull String token, @Nonnull RestoreMethodBody request) throws IOException {
String body = JsonUtil.toJson(request);
makeServiceRequest(String.format(Locale.US, SET_RESTORE_METHOD_PATH, urlEncode(token)), "PUT", body, NO_HEADERS, UNOPINIONATED_HANDLER, SealedSenderAccess.NONE);