From 7ee2de54b4b5f897e4ea89b1f72955706c1d254a Mon Sep 17 00:00:00 2001 From: Andres Tito Date: Fri, 2 Feb 2024 11:26:32 +0100 Subject: [PATCH] Change variable smtpPrefix to emailSubjectPrefix The prefix is not really tied to the SMTP protocol. If other email delivery methods are added in the future, the prefix might still be valid to use, but should not be called smtpPrefix. Signed-off-by: Andres Tito --- .../dependencytrack/model/ConfigPropertyConstants.java | 2 +- .../notification/publisher/SendMailPublisher.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/dependencytrack/model/ConfigPropertyConstants.java b/src/main/java/org/dependencytrack/model/ConfigPropertyConstants.java index cc1cfde78d..4a917cb81b 100644 --- a/src/main/java/org/dependencytrack/model/ConfigPropertyConstants.java +++ b/src/main/java/org/dependencytrack/model/ConfigPropertyConstants.java @@ -27,7 +27,7 @@ public enum ConfigPropertyConstants { GENERAL_BADGE_ENABLED("general", "badge.enabled", "false", PropertyType.BOOLEAN, "Flag to enable/disable SVG badge support from metrics"), EMAIL_SMTP_ENABLED("email", "smtp.enabled", "false", PropertyType.BOOLEAN, "Flag to enable/disable SMTP"), EMAIL_SMTP_FROM_ADDR("email", "smtp.from.address", null, PropertyType.STRING, "The from email address to use to send output SMTP mail"), - EMAIL_PREFIX("email", "smtp.prefix", "[Dependency-Track]", PropertyType.STRING, "The Prefix Subject email to use"), + EMAIL_PREFIX("email", "subject.prefix", "[Dependency-Track]", PropertyType.STRING, "The Prefix Subject email to use"), EMAIL_SMTP_SERVER_HOSTNAME("email", "smtp.server.hostname", null, PropertyType.STRING, "The hostname or IP address of the SMTP mail server"), EMAIL_SMTP_SERVER_PORT("email", "smtp.server.port", null, PropertyType.INTEGER, "The port the SMTP server listens on"), EMAIL_SMTP_USERNAME("email", "smtp.username", null, PropertyType.STRING, "The optional username to authenticate with when sending outbound SMTP mail"), diff --git a/src/main/java/org/dependencytrack/notification/publisher/SendMailPublisher.java b/src/main/java/org/dependencytrack/notification/publisher/SendMailPublisher.java index b2dd0107f3..5e805d90e4 100644 --- a/src/main/java/org/dependencytrack/notification/publisher/SendMailPublisher.java +++ b/src/main/java/org/dependencytrack/notification/publisher/SendMailPublisher.java @@ -104,7 +104,7 @@ private void sendNotification(final PublishContext ctx, Notification notificatio final String encryptedSmtpPassword; final boolean smtpSslTls; final boolean smtpTrustCert; - String smtpPrefix; + String emailSubjectPrefix; try (QueryManager qm = new QueryManager()) { smtpEnabled = qm.isEnabled(EMAIL_SMTP_ENABLED); @@ -114,8 +114,8 @@ private void sendNotification(final PublishContext ctx, Notification notificatio } smtpFrom = qm.getConfigProperty(EMAIL_SMTP_FROM_ADDR.getGroupName(), EMAIL_SMTP_FROM_ADDR.getPropertyName()).getPropertyValue(); - smtpPrefix = qm.getConfigProperty(EMAIL_PREFIX.getGroupName(), EMAIL_PREFIX.getPropertyName()).getPropertyValue(); - smtpPrefix = smtpPrefix == null ? " " : smtpPrefix; + emailSubjectPrefix = qm.getConfigProperty(EMAIL_PREFIX.getGroupName(), EMAIL_PREFIX.getPropertyName()).getPropertyValue(); + emailSubjectPrefix = emailSubjectPrefix == null ? " " : emailSubjectPrefix; smtpHostname = qm.getConfigProperty(EMAIL_SMTP_SERVER_HOSTNAME.getGroupName(), EMAIL_SMTP_SERVER_HOSTNAME.getPropertyName()).getPropertyValue(); smtpPort = Integer.parseInt(qm.getConfigProperty(EMAIL_SMTP_SERVER_PORT.getGroupName(), EMAIL_SMTP_SERVER_PORT.getPropertyName()).getPropertyValue()); smtpUser = qm.getConfigProperty(EMAIL_SMTP_USERNAME.getGroupName(), EMAIL_SMTP_USERNAME.getPropertyName()).getPropertyValue(); @@ -140,7 +140,7 @@ private void sendNotification(final PublishContext ctx, Notification notificatio final SendMail sendMail = new SendMail() .from(smtpFrom) .to(destinations) - .subject(smtpPrefix + " " + notification.getTitle() ) + .subject(emailSubjectPrefix + " " + notification.getTitle() ) .body(content) .bodyMimeType(mimeType) .host(smtpHostname)