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);
}
Aggregations