mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 00:58:07 +01:00
Remove PNI repair code
This commit is contained in:
committed by
Jon Chambers
parent
179b4a69eb
commit
fe86e15d80
@@ -520,7 +520,7 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||
return Optional.ofNullable(response.item())
|
||||
.map(item -> item.get(KEY_ACCOUNT_UUID))
|
||||
.map(this::accountByUuid)
|
||||
.map(this::fromItem);
|
||||
.map(Accounts::fromItem);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||
return Optional.ofNullable(response.item())
|
||||
.map(item -> item.get(KEY_ACCOUNT_UUID))
|
||||
.map(this::accountByUuid)
|
||||
.map(this::fromItem);
|
||||
.map(Accounts::fromItem);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -550,7 +550,7 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||
return Optional.ofNullable(response.item())
|
||||
.map(item -> item.get(KEY_ACCOUNT_UUID))
|
||||
.map(this::accountByUuid)
|
||||
.map(this::fromItem);
|
||||
.map(Accounts::fromItem);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||
public Optional<Account> getByAccountIdentifier(UUID uuid) {
|
||||
return GET_BY_UUID_TIMER.record(() ->
|
||||
Optional.ofNullable(accountByUuid(AttributeValues.fromUUID(uuid)))
|
||||
.map(this::fromItem));
|
||||
.map(Accounts::fromItem));
|
||||
}
|
||||
|
||||
public void delete(UUID uuid) {
|
||||
@@ -633,7 +633,7 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||
|
||||
final List<Account> accounts = timer.record(() -> scan(scanRequestBuilder.build(), maxCount)
|
||||
.stream()
|
||||
.map(this::fromItem)
|
||||
.map(Accounts::fromItem)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
return new AccountCrawlChunk(accounts, accounts.size() > 0 ? accounts.get(accounts.size() - 1).getUuid() : null);
|
||||
@@ -645,9 +645,8 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
// TODO Make this static once PNI repairs are complete and the call to #update(Account) is no longer needed
|
||||
@VisibleForTesting
|
||||
Account fromItem(Map<String, AttributeValue> item) {
|
||||
static Account fromItem(Map<String, AttributeValue> item) {
|
||||
if (!item.containsKey(ATTR_ACCOUNT_DATA) ||
|
||||
!item.containsKey(ATTR_ACCOUNT_E164) ||
|
||||
// TODO: eventually require ATTR_CANONICALLY_DISCOVERABLE
|
||||
@@ -667,27 +666,12 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||
accountIdentifier, account.getPhoneNumberIdentifier(), phoneNumberIdentifierFromAttribute);
|
||||
}
|
||||
|
||||
boolean shouldResetPni = false;
|
||||
|
||||
if (account.getPhoneNumberIdentifier() == null && phoneNumberIdentifierFromAttribute != null) {
|
||||
log.info("Account {} has a PNI in its attributes, but not JSON blob; will repair", accountIdentifier);
|
||||
shouldResetPni = true;
|
||||
}
|
||||
|
||||
account.setNumber(item.get(ATTR_ACCOUNT_E164).s(), phoneNumberIdentifierFromAttribute);
|
||||
account.setUuid(accountIdentifier);
|
||||
account.setUsername(AttributeValues.getString(item, ATTR_USERNAME, null));
|
||||
account.setVersion(Integer.parseInt(item.get(ATTR_VERSION).n()));
|
||||
account.setCanonicallyDiscoverable(Optional.ofNullable(item.get(ATTR_CANONICALLY_DISCOVERABLE)).map(av -> av.bool()).orElse(false));
|
||||
|
||||
if (shouldResetPni) {
|
||||
try {
|
||||
update(account);
|
||||
} catch (final Exception e) {
|
||||
log.warn("Failed to reset PNI for account {}", accountIdentifier, e);
|
||||
}
|
||||
}
|
||||
|
||||
return account;
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user