Implemented PendingGroupMessageStatusChanges for RECEIVED
This commit is contained in:
parent
5d0cc7e84c
commit
5e46ba88c9
@ -24,7 +24,8 @@ import envoy.data.MessageBuilder;
|
|||||||
@Entity
|
@Entity
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = GroupMessage.getPendingGroupMsg,
|
name = GroupMessage.getPendingGroupMsg,
|
||||||
query = "SELECT m FROM GroupMessage m JOIN m.memberMessageStatus s WHERE (KEY(s) = :userId) AND (m.creationDate > :lastSeen)"
|
query = "SELECT m FROM GroupMessage m JOIN m.memberMessageStatus s WHERE (KEY(s) = :userId) AND ((m.creationDate > :lastSeen)"
|
||||||
|
+ "OR ((m.status = envoy.data.Message$MessageStatus.RECEIVED) AND (m.receivedDate > :lastSeen)))"
|
||||||
)
|
)
|
||||||
public class GroupMessage extends Message {
|
public class GroupMessage extends Message {
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.persistence.NoResultException;
|
import javax.persistence.NoResultException;
|
||||||
@ -120,6 +121,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
|||||||
writeProxy.write(socketID, user.toCommon());
|
writeProxy.write(socketID, user.toCommon());
|
||||||
|
|
||||||
final var pendingMessages = PersistenceManager.getInstance().getPendingMessages(user);
|
final var pendingMessages = PersistenceManager.getInstance().getPendingMessages(user);
|
||||||
|
pendingMessages.removeIf(m -> m instanceof GroupMessage);
|
||||||
logger.fine("Sending " + pendingMessages.size() + " pending messages to " + user + "...");
|
logger.fine("Sending " + pendingMessages.size() + " pending messages to " + user + "...");
|
||||||
|
|
||||||
List<GroupMessage> pendingGroupMessages = PersistenceManager.getInstance().getPendingGroupMessages(user);
|
List<GroupMessage> pendingGroupMessages = PersistenceManager.getInstance().getPendingGroupMessages(user);
|
||||||
@ -146,17 +148,22 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
|||||||
if (gmsg.getMemberMessageStatus().get(user.getID()) == MessageStatus.SENT) {
|
if (gmsg.getMemberMessageStatus().get(user.getID()) == MessageStatus.SENT) {
|
||||||
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();
|
||||||
logger.info("Sending groupMessage" + groupMessage);
|
|
||||||
System.out.println(groupMessage.toString());
|
|
||||||
writeProxy.write(socketID, groupMessage);
|
writeProxy.write(socketID, groupMessage);
|
||||||
// Sending memberStatusEvent to all members (event does not exist yet I think)
|
// Sending memberStatusEvent to all members (event does not exist yet I think)
|
||||||
if (!gmsg.getMemberMessageStatus().containsValue(MessageStatus.SENT)) {
|
if (!gmsg.getMemberMessageStatus().containsValue(MessageStatus.SENT)) {
|
||||||
gmsg.setStatus(MessageStatus.RECEIVED);
|
gmsg.received();
|
||||||
// TODO: Sending MessageStatusChangeEvent to all other members
|
// Sending MessageStatusChangeEvent to all other members
|
||||||
|
for (Map.Entry<Long, MessageStatus> entry : gmsg.getMemberMessageStatus().entrySet()) {
|
||||||
|
if (entry.getKey() == connectionManager.getUserIdBySocketID(socketID)) continue;
|
||||||
|
if (connectionManager.isOnline(entry.getKey())) {
|
||||||
|
writeProxy.write(connectionManager.getSocketID(entry.getKey()), new MessageStatusChange(gmsg.toCommon()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PersistenceManager.getInstance().updateMessage(gmsg);
|
PersistenceManager.getInstance().updateMessage(gmsg);
|
||||||
} else {
|
} else {
|
||||||
// Sending memberStatusEvents and MessageStatusChange Events
|
// Sending memberStatusEvents and MessageStatusChange Events
|
||||||
|
writeProxy.write(socketID, new MessageStatusChange(gmsg.toCommon()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user