Adjusted Query and implemented pending groupMessageStatusChange proc*ing
This commit is contained in:
parent
23e07a6e91
commit
71c7d6344b
@ -21,7 +21,8 @@ import envoy.data.Group;
|
|||||||
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))"
|
+ "OR ((m.status = envoy.data.Message$MessageStatus.RECEIVED) AND (m.receivedDate > :lastSeen))"
|
||||||
+ "OR ((m.status = envoy.data.Message$MessageStatus.READ) AND (m.readDate > :lastSeen)))"
|
+ "OR ((m.status = envoy.data.Message$MessageStatus.READ) AND (m.readDate > :lastSeen))"
|
||||||
|
+ "OR ((m.lastStatusChangeDate > :lastSeen)))"
|
||||||
)
|
)
|
||||||
public class GroupMessage extends Message {
|
public class GroupMessage extends Message {
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ public class GroupMessageStatusChangeProcessor implements ObjectProcessor<GroupM
|
|||||||
|
|
||||||
// Apply the status change
|
// Apply the status change
|
||||||
gmsg.getMemberMessageStatus().replace(statusChange.getMemberID(), statusChange.get());
|
gmsg.getMemberMessageStatus().replace(statusChange.getMemberID(), statusChange.get());
|
||||||
|
gmsg.setLastStatusChangeDate(LocalDateTime.now());
|
||||||
|
|
||||||
// Notifying the other members about the status change
|
// Notifying the other members about the status change
|
||||||
gmsg.getMemberMessageStatus()
|
gmsg.getMemberMessageStatus()
|
||||||
|
@ -144,6 +144,9 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
|||||||
// Deliver the message to the user if he hasn't received it yet
|
// Deliver the message to the user if he hasn't received it yet
|
||||||
if (gmsg.getMemberMessageStatus().get(user.getID()) == SENT) {
|
if (gmsg.getMemberMessageStatus().get(user.getID()) == SENT) {
|
||||||
gmsg.getMemberMessageStatus().replace(user.getID(), RECEIVED);
|
gmsg.getMemberMessageStatus().replace(user.getID(), RECEIVED);
|
||||||
|
|
||||||
|
gmsg.setLastStatusChangeDate(LocalDateTime.now());
|
||||||
|
|
||||||
writeProxy.write(socketID, gmsgCommon);
|
writeProxy.write(socketID, gmsgCommon);
|
||||||
|
|
||||||
// Notify all online group members about the status change
|
// Notify all online group members about the status change
|
||||||
@ -163,7 +166,16 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
|||||||
PersistenceManager.getInstance().updateMessage(gmsg);
|
PersistenceManager.getInstance().updateMessage(gmsg);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// Sending group message status changes
|
||||||
|
if (gmsg.getStatus() == SENT && gmsg.getLastStatusChangeDate().isAfter(gmsg.getCreationDate())
|
||||||
|
|| gmsg.getStatus() == RECEIVED && gmsg.getLastStatusChangeDate().isAfter(gmsg.getReceivedDate())) {
|
||||||
|
gmsg.getMemberMessageStatus().forEach((memberID, memberStatus) ->
|
||||||
|
writeProxy.write(socketID, new GroupMessageStatusChange(gmsg.getID(), memberStatus, gmsg.getLastStatusChangeDate(), memberID)));
|
||||||
|
}
|
||||||
|
|
||||||
// Deliver just a status change instead of the whole message
|
// Deliver just a status change instead of the whole message
|
||||||
|
if (gmsg.getStatus() == SENT && user.getLastSeen().isBefore(gmsg.getCreationDate())
|
||||||
|
|| gmsg.getStatus() == RECEIVED && user.getLastSeen().isBefore(gmsg.getReceivedDate()))
|
||||||
writeProxy.write(socketID, new MessageStatusChange(gmsgCommon));
|
writeProxy.write(socketID, new MessageStatusChange(gmsgCommon));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user