| | |
| | | import com.gitblit.Keys; |
| | | import com.gitblit.models.Mailing; |
| | | import com.gitblit.service.MailService; |
| | | import com.google.inject.Inject; |
| | | import com.google.inject.Singleton; |
| | | |
| | | /** |
| | | * The notification manager dispatches notifications. Currently, email is the |
| | |
| | | * @author James Moger |
| | | * |
| | | */ |
| | | @Singleton |
| | | public class NotificationManager implements INotificationManager { |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger(getClass()); |
| | |
| | | |
| | | private final MailService mailService; |
| | | |
| | | @Inject |
| | | public NotificationManager(IStoredSettings settings) { |
| | | this.settings = settings; |
| | | this.mailService = new MailService(settings); |
| | |
| | | public NotificationManager stop() { |
| | | scheduledExecutor.shutdownNow(); |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isSendingMail() { |
| | | return mailService.isReady(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public void sendHtmlMail(String subject, String message, Collection<String> toAddresses) { |
| | | Mailing mail = Mailing.newHtml(); |
| | | mail.subject = subject; |
| | | mail.content = message; |
| | | mail.setRecipients(toAddresses); |
| | | send(mail); |