Implemented PendingGroupMessageStatusChanges for RECEIVED
This commit is contained in:
parent
acf58941ac
commit
a9578d6fe6
@ -24,7 +24,8 @@ import envoy.data.MessageBuilder;
|
||||
@Entity
|
||||
@NamedQuery(
|
||||
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 {
|
||||
|
||||
|
@ -11,6 +11,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.persistence.NoResultException;
|
||||
@ -120,6 +121,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
||||
writeProxy.write(socketID, user.toCommon());
|
||||
|
||||
final var pendingMessages = PersistenceManager.getInstance().getPendingMessages(user);
|
||||
pendingMessages.removeIf(m -> m instanceof GroupMessage);
|
||||
logger.fine("Sending " + pendingMessages.size() + " pending messages to " + 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) {
|
||||
gmsg.getMemberMessageStatus().replace(user.getID(), MessageStatus.RECEIVED);
|
||||
envoy.data.GroupMessage groupMessage = gmsg.toCommon();
|
||||
logger.info("Sending groupMessage" + groupMessage);
|
||||
System.out.println(groupMessage.toString());
|
||||
writeProxy.write(socketID, groupMessage);
|
||||
// Sending memberStatusEvent to all members (event does not exist yet I think)
|
||||
if (!gmsg.getMemberMessageStatus().containsValue(MessageStatus.SENT)) {
|
||||
gmsg.setStatus(MessageStatus.RECEIVED);
|
||||
// TODO: Sending MessageStatusChangeEvent to all other members
|
||||
gmsg.received();
|
||||
// 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);
|
||||
} else {
|
||||
// Sending memberStatusEvents and MessageStatusChange Events
|
||||
writeProxy.write(socketID, new MessageStatusChange(gmsg.toCommon()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user