Add server side contact deletion

This commit is contained in:
2020-10-10 22:25:39 +02:00
committed by KSKE Git
parent 12184848b6
commit a515ec961a
9 changed files with 122 additions and 20 deletions

View File

@ -13,6 +13,7 @@ import javax.persistence.NoResultException;
import envoy.data.LoginCredentials;
import envoy.event.*;
import envoy.event.contact.ContactDeletionSinceLastLogin;
import envoy.server.data.*;
import envoy.server.net.*;
import envoy.server.util.*;
@ -104,6 +105,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
user.setStatus(ONLINE);
user.setPasswordHash(PasswordUtil.hash(credentials.getPassword()));
user.setContacts(new HashSet<>());
user.setLatestContactDeletion(Instant.EPOCH);
persistenceManager.addContact(user);
logger.info("Registered new " + user);
}
@ -208,5 +210,8 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
// Complete the handshake
writeProxy.write(socketID, user.toCommon());
// Notify the user if a contact deletion has happened since he last logged in
if (user.getLatestContactDeletion().isAfter(user.getLastSeen())) writeProxy.write(socketID, new ContactDeletionSinceLastLogin());
}
}