aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server-common/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2018-07-31 08:56:35 +0200
committerSonarTech <sonartech@sonarsource.com>2018-08-02 20:21:37 +0200
commit9de7b45dbff34a72f8c56fe380bd3d43cdb34e8d (patch)
tree7b7d480080fb75577c0c3c9112db841577f73894 /server/sonar-server-common/src
parentc1931745e1dfe85df57306b325469b638e588910 (diff)
downloadsonarqube-9de7b45dbff34a72f8c56fe380bd3d43cdb34e8d.tar.gz
sonarqube-9de7b45dbff34a72f8c56fe380bd3d43cdb34e8d.zip
Optimize EmailNotificationChannel when SMTP is not configured
No need to load emails of recipients from database if SMTP server is not configured.
Diffstat (limited to 'server/sonar-server-common/src')
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java b/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java
index 87235eecceb..d9e68931cea 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java
@@ -96,11 +96,17 @@ public class EmailNotificationChannel extends NotificationChannel {
@Override
public boolean deliver(Notification notification, String username) {
+ if (StringUtils.isBlank(configuration.getSmtpHost())) {
+ LOG.debug("SMTP host was not configured - email will not be sent");
+ return false;
+ }
+
User user = findByLogin(username);
if (user == null || StringUtils.isBlank(user.email())) {
LOG.debug("User does not exist or has no email: {}", username);
return false;
}
+
EmailMessage emailMessage = format(notification);
if (emailMessage != null) {
emailMessage.setTo(user.email());