Search in sources :

Example 1 with NotificationUserIterator

use of org.xwiki.notifications.notifiers.internal.email.NotificationUserIterator in project xwiki-platform by xwiki.

the class LiveNotificationEmailSender method sendEmails.

/**
 * Send live notification e-mails regarding the given event for the users that are concerned by this event and that
 * have enabled live notifications.
 * @param event the event that should be sent to the users
 */
public void sendEmails(CompositeEvent event) {
    DocumentReference templateReference = new DocumentReference(this.wikiDescriptorManager.getCurrentWikiId(), Arrays.asList("XWiki", "Notifications"), "MailTemplate");
    // Get a list of users that have enabled the live e-mail notifications.
    NotificationUserIterator notificationUserIterator = this.notificationUserIteratorProvider.get();
    notificationUserIterator.initialize(NotificationEmailInterval.LIVE);
    LiveMimeMessageIterator liveNotificationMessageIterator = this.liveMimeMessageIteratorProvider.get();
    liveNotificationMessageIterator.initialize(notificationUserIterator, new HashMap<>(), event, templateReference);
    Session session = this.sessionFactory.create(Collections.emptyMap());
    MailListener mailListener = mailListenerProvider.get();
    // Pass it to the message sender to send it asynchronously.
    mailSender.sendAsynchronously(liveNotificationMessageIterator, session, mailListener);
}
Also used : MailListener(org.xwiki.mail.MailListener) NotificationUserIterator(org.xwiki.notifications.notifiers.internal.email.NotificationUserIterator) DocumentReference(org.xwiki.model.reference.DocumentReference) Session(javax.mail.Session)

Aggregations

Session (javax.mail.Session)1 MailListener (org.xwiki.mail.MailListener)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 NotificationUserIterator (org.xwiki.notifications.notifiers.internal.email.NotificationUserIterator)1