fixed bug using wrong id of message
This commit is contained in:
parent
0704f9a5c3
commit
cba20900ba
@ -3,6 +3,8 @@ package envoy.server.processors;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.EntityExistsException;
|
||||
|
||||
import envoy.data.Message;
|
||||
import envoy.data.Message.MessageStatus;
|
||||
import envoy.data.MessageBuilder;
|
||||
@ -29,10 +31,9 @@ public class MessageProcessor implements ObjectProcessor<Message> {
|
||||
public void process(Message message, long socketID, ObjectWriteProxy writeProxy) {
|
||||
message.nextStatus();
|
||||
ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||
Contact recipient = PersistenceManager.getInstance().getContactByID(message.getID());
|
||||
Contact recipient = PersistenceManager.getInstance().getContactByID(message.getRecipientID());
|
||||
|
||||
if (recipient instanceof envoy.server.data.User) {
|
||||
System.out.println("The received message is a direct message.");
|
||||
sendToUser(connectionManager, message, writeProxy);
|
||||
// Sending a messageStatusChangeEvent to the sender
|
||||
try {
|
||||
@ -42,7 +43,6 @@ public class MessageProcessor implements ObjectProcessor<Message> {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println("The received message is a group message.");
|
||||
final var members = PersistenceManager.getInstance().getGroupByID(message.getRecipientID()).getContacts();
|
||||
final var generator = IDGeneratorRequestProcessor.createIDGenerator(members.size());
|
||||
members.forEach(user -> {
|
||||
@ -59,7 +59,11 @@ public class MessageProcessor implements ObjectProcessor<Message> {
|
||||
// copies of the original message. (Not at this location)
|
||||
});
|
||||
}
|
||||
PersistenceManager.getInstance().addMessage(new envoy.server.data.Message(message));
|
||||
try {
|
||||
PersistenceManager.getInstance().addMessage(new envoy.server.data.Message(message));
|
||||
} catch (EntityExistsException e) {
|
||||
System.err.println("Received a message with an id that already exists");
|
||||
}
|
||||
}
|
||||
|
||||
private void sendToUser(ConnectionManager connectionManager, Message message, ObjectWriteProxy writeProxy) {
|
||||
|
Reference in New Issue
Block a user