Skip to content

Commit

Permalink
1497 - Use odd.platform-base-url property instead of PLATFORM_HOST_UR…
Browse files Browse the repository at this point in the history
…L environment variable for email notifications.
  • Loading branch information
Vladysl committed Nov 2, 2023
1 parent 609c5de commit 2ae23a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public NotificationSender<AlertNotificationMessage> webhookNotificationSender(
@ConditionalOnProperty(name = "notifications.receivers.email.sender")
public NotificationSender<AlertNotificationMessage> emailNotificationSender(
@Value("${notifications.receivers.email.notification.emails}") final String notificationEmails,
@Value("${odd.platform-base-url:http://localhost:8080}") final String platformHost,
final freemarker.template.Configuration configuration,
final HttpClient httpClient,
final JavaMailSender mailSender
Expand All @@ -109,6 +110,7 @@ public NotificationSender<AlertNotificationMessage> emailNotificationSender(
return new EmailNotificationSender(httpClient,
mailSender,
configuration,
platformHost,
List.of(notificationEmails.trim().split(",")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ public class EmailNotificationSender extends AbstractNotificationSender<AlertNot
private final JavaMailSender emailSender;
private final List<String> notificationsEmails;
private final Configuration configuration;
private final String platformHost;

public EmailNotificationSender(final HttpClient httpClient,
final JavaMailSender mailSender,
final Configuration configuration,
final String platformHost,
final List<String> notificationsEmails) {
super(httpClient);
this.emailSender = mailSender;
this.configuration = configuration;
this.platformHost = platformHost;
this.notificationsEmails = notificationsEmails;
}

Expand Down Expand Up @@ -60,10 +63,7 @@ public void send(final AlertNotificationMessage message) throws InterruptedExcep
private String getEmailContent(final AlertNotificationMessage message) throws IOException, TemplateException {
final StringWriter stringWriter = new StringWriter();
final Map<String, Object> model = new HashMap<>();
final String host = StringUtils.isBlank(System.getenv("PLATFORM_HOST_URL"))
? "http://localhost:8080"
: System.getenv("PLATFORM_HOST_URL");
final String alertUrl = host + ALERT_PATH.replace("{dataEntityId}",
final String alertUrl = platformHost + ALERT_PATH.replace("{dataEntityId}",
String.valueOf(message.getDataEntity().id()));

model.put("dataEntityId", String.valueOf(message.getDataEntity().id()));
Expand Down

0 comments on commit 2ae23a6

Please sign in to comment.