mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 19:48:07 +01:00
Record account deletion reasons.
This commit is contained in:
committed by
Jon Chambers
parent
d82b3dc429
commit
23ca011ac1
@@ -604,7 +604,7 @@ public class AccountController {
|
||||
@DELETE
|
||||
@Path("/me")
|
||||
public void deleteAccount(@Auth Account account) {
|
||||
accounts.delete(account);
|
||||
accounts.delete(account, AccountsManager.DeletionReason.USER_REQUEST);
|
||||
}
|
||||
|
||||
private boolean shouldAutoBlock(String requester) {
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AccountCleaner extends AccountDatabaseCrawlerListener {
|
||||
expiredAccountsMeter.mark();
|
||||
|
||||
if (accountUpdateCount < MAX_ACCOUNT_UPDATES_PER_CHUNK) {
|
||||
accountsManager.delete(account);
|
||||
accountsManager.delete(account, AccountsManager.DeletionReason.EXPIRED);
|
||||
accountUpdateCount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +56,9 @@ public class AccountsManager {
|
||||
private static final Timer redisUuidGetTimer = metricRegistry.timer(name(AccountsManager.class, "redisUuidGet" ));
|
||||
private static final Timer redisDeleteTimer = metricRegistry.timer(name(AccountsManager.class, "redisDelete" ));
|
||||
|
||||
private static final String DELETE_COUNTER_NAME = name(AccountsManager.class, "deleteCounter");
|
||||
private static final String COUNTRY_CODE_TAG_NAME = "country";
|
||||
private static final String DELETE_COUNTER_NAME = name(AccountsManager.class, "deleteCounter");
|
||||
private static final String COUNTRY_CODE_TAG_NAME = "country";
|
||||
private static final String DELETION_REASON_TAG_NAME = "reason";
|
||||
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(AccountsManager.class);
|
||||
@@ -72,6 +73,18 @@ public class AccountsManager {
|
||||
private final ProfilesManager profilesManager;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
public enum DeletionReason {
|
||||
ADMIN_DELETED("admin"),
|
||||
EXPIRED ("expired"),
|
||||
USER_REQUEST ("userRequest");
|
||||
|
||||
private final String tagValue;
|
||||
|
||||
DeletionReason(final String tagValue) {
|
||||
this.tagValue = tagValue;
|
||||
}
|
||||
}
|
||||
|
||||
public AccountsManager(Accounts accounts, DirectoryManager directory, FaultTolerantRedisCluster cacheCluster, final DirectoryQueue directoryQueue, final Keys keys, final MessagesManager messagesManager, final UsernamesManager usernamesManager, final ProfilesManager profilesManager) {
|
||||
this.accounts = accounts;
|
||||
this.directory = directory;
|
||||
@@ -143,7 +156,7 @@ public class AccountsManager {
|
||||
return accounts.getAllFrom(uuid, length);
|
||||
}
|
||||
|
||||
public void delete(final Account account) {
|
||||
public void delete(final Account account, final DeletionReason deletionReason) {
|
||||
try (final Timer.Context ignored = deleteTimer.time()) {
|
||||
usernamesManager.delete(account.getUuid());
|
||||
directoryQueue.deleteAccount(account);
|
||||
@@ -155,7 +168,10 @@ public class AccountsManager {
|
||||
databaseDelete(account);
|
||||
}
|
||||
|
||||
Metrics.counter(DELETE_COUNTER_NAME, COUNTRY_CODE_TAG_NAME, Util.getCountryCode(account.getNumber())).increment();
|
||||
Metrics.counter(DELETE_COUNTER_NAME,
|
||||
COUNTRY_CODE_TAG_NAME, Util.getCountryCode(account.getNumber()),
|
||||
DELETION_REASON_TAG_NAME, deletionReason.tagValue)
|
||||
.increment();
|
||||
}
|
||||
|
||||
private void updateDirectory(Account account) {
|
||||
|
||||
@@ -106,7 +106,7 @@ public class DeleteUserCommand extends EnvironmentCommand<WhisperServerConfigura
|
||||
Optional<Account> account = accountsManager.get(user);
|
||||
|
||||
if (account.isPresent()) {
|
||||
accountsManager.delete(account.get());
|
||||
accountsManager.delete(account.get(), AccountsManager.DeletionReason.ADMIN_DELETED);
|
||||
logger.warn("Removed " + account.get().getNumber());
|
||||
} else {
|
||||
logger.warn("Account not found");
|
||||
|
||||
Reference in New Issue
Block a user