Fix instrumentation for re-registration of recently-deleted accounts

This commit is contained in:
Jon Chambers 2023-10-17 11:43:11 -04:00 committed by Jon Chambers
parent ae976ef8d6
commit 162b27323e
1 changed files with 7 additions and 4 deletions

View File

@ -196,9 +196,12 @@ public class AccountsManager {
account.setNumber(number, phoneNumberIdentifiers.getPhoneNumberIdentifier(number));
final Optional<UUID> maybeRecentlyDeletedAccountIdentifier =
accounts.findRecentlyDeletedAccountIdentifier(number);
// Reuse the ACI from any recently-deleted account with this number to cover cases where somebody is
// re-registering.
account.setUuid(accounts.findRecentlyDeletedAccountIdentifier(number).orElseGet(UUID::randomUUID));
account.setUuid(maybeRecentlyDeletedAccountIdentifier.orElseGet(UUID::randomUUID));
account.addDevice(device);
account.setRegistrationLockFromAttributes(accountAttributes);
account.setUnidentifiedAccessKey(accountAttributes.getUnidentifiedAccessKey());
@ -245,10 +248,10 @@ public class AccountsManager {
if (freshUser) {
tags = Tags.of("type", "new");
} else if (!originalUuid.equals(actualUuid)) {
tags = Tags.of("type", "re-registration");
} else {
} else if (maybeRecentlyDeletedAccountIdentifier.isPresent()) {
tags = Tags.of("type", "recently-deleted");
} else {
tags = Tags.of("type", "re-registration");
}
Metrics.counter(CREATE_COUNTER_NAME, tags).increment();