Fix notifying the sender about a message delivery
This addresses bugs in two instances of delivery notification: * the sender is online -> no event was sent * the sender comes online later -> wrong status (SENT) was sent
This commit is contained in:
@ -109,14 +109,21 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
||||
|
||||
final var pendingMessages = PersistenceManager.getInstance().getPendingMessages(user);
|
||||
logger.fine("Sending " + pendingMessages.size() + " pending messages to " + user + "...");
|
||||
|
||||
for (var msg : pendingMessages) {
|
||||
final var msgCommon = msg.toCommon();
|
||||
if (msg.getStatus() == MessageStatus.SENT) {
|
||||
|
||||
// Send the message
|
||||
writeProxy.write(socketID, msgCommon);
|
||||
msg.received();
|
||||
if (connectionManager.isOnline(msg.getSender().getID()))
|
||||
writeProxy.write(connectionManager.getSocketID(msg.getSender().getID()), new MessageStatusChange(msgCommon));
|
||||
PersistenceManager.getInstance().updateMessage(msg);
|
||||
|
||||
// Notify the sender about the delivery
|
||||
if (connectionManager.isOnline(msg.getSender().getID())) {
|
||||
msgCommon.nextStatus();
|
||||
writeProxy.write(connectionManager.getSocketID(msg.getSender().getID()), new MessageStatusChange(msgCommon));
|
||||
}
|
||||
} else writeProxy.write(socketID, new MessageStatusChange(msgCommon));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user