Search in sources :

Example 1 with MessageId

use of edu.stanford.bmir.protege.web.server.mail.MessageId in project webprotege by protegeproject.

the class CommentNotificationEmailer method sendEmailToUsers.

private void sendEmailToUsers(@Nonnull Collection<UserDetails> userDetails, @Nonnull ProjectId projectId, @Nonnull OWLEntityData entityData, @Nonnull EntityDiscussionThread discussionThread, @Nonnull Comment postedComment) {
    List<String> emailAddresses = userDetails.stream().map(UserDetails::getEmailAddress).filter(Optional::isPresent).map(Optional::get).collect(toList());
    MessageId postedCommentMessageId = messageIdGenerator.generateCommentMessageId(projectId, postedComment.getId());
    List<MessageHeader> messageHeaders = new ArrayList<>();
    int commentIndex = discussionThread.getComments().indexOf(postedComment);
    if (commentIndex != 0) {
        // Reply to the original message
        MessageId headCommentMessageId = messageIdGenerator.generateCommentMessageId(projectId, discussionThread.getComments().get(0).getId());
        messageHeaders.add(MessageHeader.inReplyTo(headCommentMessageId.getId()));
        messageHeaders.add(MessageHeader.references(headCommentMessageId.getId()));
    }
    sendMail.sendMail(postedCommentMessageId, emailAddresses, formatSubjectLine(projectId, entityData, discussionThread, postedComment), formatMessage(projectId, entityData, discussionThread, postedComment), messageHeaders.toArray(new MessageHeader[messageHeaders.size()]));
}
Also used : Optional(java.util.Optional) ArrayList(java.util.ArrayList) MessageHeader(edu.stanford.bmir.protege.web.server.mail.MessageHeader) MessageId(edu.stanford.bmir.protege.web.server.mail.MessageId)

Aggregations

MessageHeader (edu.stanford.bmir.protege.web.server.mail.MessageHeader)1 MessageId (edu.stanford.bmir.protege.web.server.mail.MessageId)1 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1