Implemented sending RECEIVED GroupMessageStatusChanges

If a member logs in and receives pending groupMessages, there are now
groupMessageStatusChanges sent to all other members, that are online and
have already received the groupMessage.
This commit is contained in:
DieGurke 2020-07-03 17:46:37 +02:00
parent 4b9cdcb8be
commit 75dc563a07

View File

@ -19,6 +19,7 @@ import javax.persistence.NoResultException;
import enovy.server.util.VersionUtils; import enovy.server.util.VersionUtils;
import envoy.data.LoginCredentials; import envoy.data.LoginCredentials;
import envoy.data.Message.MessageStatus; import envoy.data.Message.MessageStatus;
import envoy.event.GroupMessageStatusChange;
import envoy.event.HandshakeRejection; import envoy.event.HandshakeRejection;
import envoy.event.MessageStatusChange; import envoy.event.MessageStatusChange;
import envoy.server.data.GroupMessage; import envoy.server.data.GroupMessage;
@ -149,7 +150,22 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
gmsg.getMemberMessageStatus().replace(user.getID(), MessageStatus.RECEIVED); gmsg.getMemberMessageStatus().replace(user.getID(), MessageStatus.RECEIVED);
envoy.data.GroupMessage groupMessage = gmsg.toCommon(); envoy.data.GroupMessage groupMessage = gmsg.toCommon();
writeProxy.write(socketID, groupMessage); writeProxy.write(socketID, groupMessage);
// Sending memberStatusEvent to all members (event does not exist yet I think) // Sending GroupMessageStatusChanges to all members, that already received the
// groupMessage.
gmsg.getMemberMessageStatus().keySet().stream()
.filter(k -> (gmsg.getMemberMessageStatus().get(k) == MessageStatus.RECEIVED
|| gmsg.getMemberMessageStatus().get(k) == MessageStatus.READ) && connectionManager.getUserIdBySocketID(socketID) != k)
.forEach(k -> {
if (connectionManager.isOnline(k)) try {
writeProxy.write(connectionManager.getSocketID(k),
(new GroupMessageStatusChange(gmsg.getID(), MessageStatus.RECEIVED, LocalDateTime.now(),
connectionManager.getUserIdBySocketID(socketID))));
} catch (IOException e) {
// TODO Maybe Try Catch block is not necessarily needed but if so write proper
// logger statement here.
e.printStackTrace();
}
});
if (!gmsg.getMemberMessageStatus().containsValue(MessageStatus.SENT)) { if (!gmsg.getMemberMessageStatus().containsValue(MessageStatus.SENT)) {
gmsg.received(); gmsg.received();
// Sending MessageStatusChangeEvent to all other members // Sending MessageStatusChangeEvent to all other members