mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-01 12:36:47 +00:00
Return a non-stale account from base authenticator when last seen is updated
This commit is contained in:
1 parent
817866caf3
commit
01ef855157
4 files changed
+38
-12
No files matched your search
+5
-4
@@ -83,8 +83,7 @@ public class BaseAccountAuthenticator {
|
||||
if (device.get().getAuthenticationCredentials().verify(basicCredentials.getPassword())) {
|
||||
succeeded = true;
|
||||
account.get().setAuthenticatedDevice(device.get());
|
||||
updateLastSeen(account.get(), device.get());
|
||||
return account;
|
||||
return Optional.of(updateLastSeen(account.get(), device.get()));
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
@@ -109,7 +108,7 @@ public class BaseAccountAuthenticator {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void updateLastSeen(Account account, Device device) {
|
||||
public Account updateLastSeen(Account account, Device device) {
|
||||
final long lastSeenOffsetSeconds = Math.abs(account.getUuid().getLeastSignificantBits()) % ChronoUnit.DAYS.getDuration().toSeconds();
|
||||
final long todayInMillisWithOffset = Util.todayInMillisGivenOffsetFromNow(clock, Duration.ofSeconds(lastSeenOffsetSeconds).negated());
|
||||
|
||||
@@ -117,8 +116,10 @@ public class BaseAccountAuthenticator {
|
||||
Metrics.summary(DAYS_SINCE_LAST_SEEN_DISTRIBUTION_NAME, IS_PRIMARY_DEVICE_TAG, String.valueOf(device.isMaster()))
|
||||
.record(Duration.ofMillis(todayInMillisWithOffset - device.getLastSeen()).toDays());
|
||||
|
||||
accountsManager.updateDevice(account, device.getId(), d -> d.setLastSeen(Util.todayInMillis(clock)));
|
||||
return accountsManager.updateDevice(account, device.getId(), d -> d.setLastSeen(Util.todayInMillis(clock)));
|
||||
}
|
||||
|
||||
return account;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user