Skip to content

Commit

Permalink
Retire RemoveE164RecentlyDeletedAccountsCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-signal committed Dec 2, 2024
1 parent 142e2cb commit fb6c4ec
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@
import org.whispersystems.textsecuregcm.workers.MessagePersisterServiceCommand;
import org.whispersystems.textsecuregcm.workers.NotifyIdleDevicesCommand;
import org.whispersystems.textsecuregcm.workers.ProcessScheduledJobsServiceCommand;
import org.whispersystems.textsecuregcm.workers.RemoveE164RecentlyDeletedAccountsCommand;
import org.whispersystems.textsecuregcm.workers.RemoveExpiredAccountsCommand;
import org.whispersystems.textsecuregcm.workers.RemoveExpiredBackupsCommand;
import org.whispersystems.textsecuregcm.workers.RemoveExpiredLinkedDevicesCommand;
Expand Down Expand Up @@ -330,8 +329,6 @@ public void initialize(final Bootstrap<WhisperServerConfiguration> bootstrap) {
bootstrap.addCommand(new ProcessScheduledJobsServiceCommand("process-idle-device-notification-jobs",
"Processes scheduled jobs to send notifications to idle devices",
new IdleDeviceNotificationSchedulerFactory()));

bootstrap.addCommand(new RemoveE164RecentlyDeletedAccountsCommand());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import software.amazon.awssdk.services.dynamodb.model.CancellationReason;
import software.amazon.awssdk.services.dynamodb.model.ConditionalCheckFailedException;
import software.amazon.awssdk.services.dynamodb.model.Delete;
import software.amazon.awssdk.services.dynamodb.model.DeleteItemRequest;
import software.amazon.awssdk.services.dynamodb.model.GetItemRequest;
import software.amazon.awssdk.services.dynamodb.model.GetItemResponse;
import software.amazon.awssdk.services.dynamodb.model.Put;
Expand Down Expand Up @@ -1247,36 +1246,6 @@ Flux<Account> getAll(final int segments, final Scheduler scheduler) {
.sequential();
}

CompletableFuture<Void> removeRecentlyDeletedAccountRecord(final String e164) {
return asyncClient.deleteItem(DeleteItemRequest.builder()
.tableName(deletedAccountsTableName)
.key(Map.of(DELETED_ACCOUNTS_KEY_ACCOUNT_PNI, AttributeValues.fromString(e164)))
.build())
.thenRun(Util.NOOP);
}

Flux<String> getE164sForRecentlyDeletedAccounts(final int segments, final Scheduler scheduler) {
if (segments < 1) {
throw new IllegalArgumentException("Total number of segments must be positive");
}

return Flux.range(0, segments)
.parallel()
.runOn(scheduler)
.flatMap(segment -> dynamoDbAsyncClient.scanPaginator(ScanRequest.builder()
.tableName(deletedAccountsTableName)
.consistentRead(true)
.segment(segment)
.totalSegments(segments)
.filterExpression("begins_with(#key, :e164Prefix)")
.expressionAttributeNames(Map.of("#key", DELETED_ACCOUNTS_KEY_ACCOUNT_PNI))
.expressionAttributeValues(Map.of(":e164Prefix", AttributeValue.fromS("+")))
.build())
.items())
.map(item -> item.get(DELETED_ACCOUNTS_KEY_ACCOUNT_PNI).s())
.sequential();
}

@Nonnull
private Optional<Account> getByIndirectLookup(
final Timer timer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1212,14 +1212,6 @@ public Optional<UUID> findRecentlyDeletedPhoneNumberIdentifier(final UUID accoun
return accounts.findRecentlyDeletedPhoneNumberIdentifier(accountIdentifier);
}

public Flux<String> getE164sForRecentlyDeletedAccounts(final int segments, final Scheduler scheduler) {
return accounts.getE164sForRecentlyDeletedAccounts(segments, scheduler);
}

public CompletableFuture<Void> removeRecentlyDeletedAccountRecord(final String e164) {
return accounts.removeRecentlyDeletedAccountRecord(e164);
}

public Flux<Account> streamAllFromDynamo(final int segments, final Scheduler scheduler) {
return accounts.getAll(segments, scheduler);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.mockito.Mockito.when;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;
Expand Down Expand Up @@ -1708,32 +1707,6 @@ public void testInvalidDeviceIdDeserialization() throws Exception {
assertInstanceOf(DeviceIdDeserializer.DeviceIdDeserializationException.class, cause);
}

@Test
public void getE164sForRecentlyDeletedAccounts() {
final UUID accountIdentifier = UUID.randomUUID();
final UUID phoneNumberIdentifier = UUID.randomUUID();
final String phoneNumber = PhoneNumberUtil.getInstance().format(
PhoneNumberUtil.getInstance().getExampleNumber("US"),
PhoneNumberUtil.PhoneNumberFormat.E164);

final Account deletedAccount = generateAccount(phoneNumber, accountIdentifier, phoneNumberIdentifier);
createAccount(deletedAccount);
accounts.delete(deletedAccount.getUuid(), List.of()).join();

// Artificially insert this row to simulate legacy data
DYNAMO_DB_EXTENSION.getDynamoDbClient().putItem(PutItemRequest.builder()
.tableName(Tables.DELETED_ACCOUNTS.tableName())
.item(Map.of(
Accounts.DELETED_ACCOUNTS_KEY_ACCOUNT_PNI, AttributeValues.fromString(phoneNumber),
Accounts.DELETED_ACCOUNTS_ATTR_ACCOUNT_UUID, AttributeValues.fromUUID(accountIdentifier),
Accounts.DELETED_ACCOUNTS_ATTR_EXPIRES, AttributeValues.fromLong(clock.instant().plus(Accounts.DELETED_ACCOUNTS_TIME_TO_LIVE).getEpochSecond())))
.build());

assertEquals(
List.of(phoneNumber),
accounts.getE164sForRecentlyDeletedAccounts(1, Schedulers.immediate()).collectList().block());
}

private static Device generateDevice(byte id) {
return DevicesHelper.createDevice(id);
}
Expand Down

0 comments on commit fb6c4ec

Please sign in to comment.