Fix bug where multiple recipients not showing in show() command
This commit is contained in:
parent
8759834955
commit
7604f4dee3
@ -61,12 +61,8 @@ public class DMTPConnection implements Runnable {
|
|||||||
out.println("ok bye");
|
out.println("ok bye");
|
||||||
shutdown();
|
shutdown();
|
||||||
} else if ("send".equals(userInput)) {
|
} else if ("send".equals(userInput)) {
|
||||||
try {
|
storeMessage();
|
||||||
storeMessage();
|
out.println("ok");
|
||||||
out.println("ok");
|
|
||||||
} catch (UnknownRecipientException e) {
|
|
||||||
out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
} else if ("to".equals(userInput.split("\\s+")[0])) {
|
} else if ("to".equals(userInput.split("\\s+")[0])) {
|
||||||
msg.setTo(new ArrayList<>());
|
msg.setTo(new ArrayList<>());
|
||||||
String[] emailAddresses = userInput.split("\\s+")[1].split(",");
|
String[] emailAddresses = userInput.split("\\s+")[1].split(",");
|
||||||
@ -86,6 +82,10 @@ public class DMTPConnection implements Runnable {
|
|||||||
msg.addTo(add);
|
msg.addTo(add);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.info("Address " + emailAddress + " does not belong to this domain. Adding anyway...");
|
||||||
|
msg.addTo(add);
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.println("ok " + count);
|
out.println("ok " + count);
|
||||||
@ -125,21 +125,14 @@ public class DMTPConnection implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void storeMessage() throws UnknownRecipientException {
|
private synchronized void storeMessage() {
|
||||||
logger.info("Storing message " + msg.toString());
|
logger.info("Storing message " + msg.toString());
|
||||||
this.msg.setId(MailboxServer.id++);
|
this.msg.setId(MailboxServer.id++);
|
||||||
String errorUnknownRecipient = "";
|
|
||||||
for (Email recipient : this.msg.getTo()) {
|
for (Email recipient : this.msg.getTo()) {
|
||||||
if (this.messageStorage.containsKey(recipient)) {
|
if (this.messageStorage.containsKey(recipient)) {
|
||||||
this.messageStorage.get(recipient).add(this.msg);
|
this.messageStorage.get(recipient).add(this.msg);
|
||||||
} else {
|
|
||||||
if (errorUnknownRecipient.isBlank())
|
|
||||||
errorUnknownRecipient = "error unknown recipient " + recipient.getUsername();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!errorUnknownRecipient.isBlank())
|
|
||||||
throw new UnknownRecipientException(errorUnknownRecipient);
|
|
||||||
this.msg = new Message();
|
this.msg = new Message();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user