protected PrivateMessageSent createMessageEvent(MessageData messageData) {
User sender = userReader.getUser(authorizedUserService.getCurrentUserId());
//Setup the recipients
Collection<User> recipients = messageData.getRecipients();
PrivateMessageSent event = new PrivateMessageSent();
event.setBody(messageData.getBody());
event.setSubject(messageData.getSubject());
event.setSender(sender);
event.setLocale(localeService.getCurrentLocale());
for(User recipient: recipients) {
if(recipient == null) {
String unknownRecipientMessage = MessageFormat.format(getString(MKEY_UNKNOWN_RECIPIENT), new Object[]{recipient});
recipientsListLabel.error(unknownRecipientMessage);
throw new BusinessLogicException(unknownRecipientMessage);
}
}
event.setRecipients(recipients);
return event;
}