Fixed contacts initialisation, socket logout error

additionally fixed small spelling mistakes
This commit is contained in:
delvh
2020-02-04 21:09:59 +01:00
parent f11ed4a585
commit 5fcbf59349
4 changed files with 19 additions and 20 deletions

View File

@ -44,19 +44,15 @@ public class LoginCredentialProcessor implements ObjectProcessor<LoginCredential
// Not logged in successfully
if (user == null) return;
ConnectionManager.getInstance().registerUser(user.getId(), socketId);
// notifies contacts of this users online-going and updates his status in the
// database
UserStatusChangeProcessor.updateUserStatus(new UserStatusChangeEvent(user.toCommonUser()));
ConnectionManager.getInstance().registerUser(user.getId(), socketId);
// Create contacts
List<User> users = PersistenceManager.getPersistenceManager()
.getContacts(user)
.stream()
.map(envoy.server.data.User::toCommonUser)
.collect(Collectors.toList());
Contacts contacts = new Contacts(user.getId(), users);
Contacts contacts = new Contacts(user.getId(),
user.getContacts().stream().map(envoy.server.data.User::toCommonUser).collect(Collectors.toList()));
// Complete handshake
System.out.println("Sending user...");
@ -83,6 +79,7 @@ public class LoginCredentialProcessor implements ObjectProcessor<LoginCredential
user.setLastSeen(new Date());
user.setStatus(User.UserStatus.ONLINE);
user.setPasswordHash(credentials.getPasswordHash());
user.setContacts(PersistenceManager.getPersistenceManager().getContacts(user));
persistenceManager.addUser(user);
} else {
user = persistenceManager.getUserByName(credentials.getName());