From 134faf33d26021aae63800acc4603b453964dbbc Mon Sep 17 00:00:00 2001 From: Bernardus Jansen Date: Sun, 22 May 2016 10:32:18 +0200 Subject: [PATCH] Customizable From header Signed-off-by: Bernardus Jansen --- .../command/AdvancedSettingsCommand.java | 9 +++++++ .../AdvancedSettingsController.java | 2 ++ .../player/controller/MultiController.java | 2 +- .../player/service/SettingsService.java | 10 ++++++++ .../player/i18n/ResourceBundle_en.properties | 11 +++++--- .../player/i18n/ResourceBundle_nl.properties | 3 ++- .../webapp/WEB-INF/jsp/advancedSettings.jsp | 25 +++++++++++-------- 7 files changed, 45 insertions(+), 17 deletions(-) diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java index 093c34b3..eaad28af 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java @@ -45,6 +45,7 @@ public class AdvancedSettingsCommand { private String smtpPort; private String smtpUser; private String smtpPassword; + private String smtpFrom; public String getDownloadLimit() { return downloadLimit; @@ -173,4 +174,12 @@ public class AdvancedSettingsCommand { public void setSmtpPassword(String smtpPassword) { this.smtpPassword = smtpPassword; } + + public String getSmtpFrom() { + return smtpFrom; + } + + public void setSmtpFrom(String smtpFrom) { + this.smtpFrom = smtpFrom; + } } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java index c822717a..3622bedc 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java @@ -51,6 +51,7 @@ public class AdvancedSettingsController extends SimpleFormController { command.setSmtpEncryption(settingsService.getSmtpEncryption()); command.setSmtpPort(settingsService.getSmtpPort()); command.setSmtpUser(settingsService.getSmtpUser()); + command.setSmtpFrom(settingsService.getSmtpFrom()); return command; } @@ -83,6 +84,7 @@ public class AdvancedSettingsController extends SimpleFormController { settingsService.setSmtpEncryption(command.getSmtpEncryption()); settingsService.setSmtpPort(command.getSmtpPort()); settingsService.setSmtpUser(command.getSmtpUser()); + settingsService.setSmtpFrom(command.getSmtpFrom()); if (StringUtils.isNotEmpty(command.getSmtpPassword())) { settingsService.setSmtpPassword(command.getSmtpPassword()); diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java index 52baad91..8564e46e 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java @@ -168,7 +168,7 @@ public class MultiController extends MultiActionController { try { Message message = new MimeMessage(session); - message.setFrom(new InternetAddress("libresonic@libresonic.org")); + message.setFrom(new InternetAddress(settingsService.getSmtpFrom())); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(email)); message.setSubject("Libresonic Password"); message.setText("Hi there!\n\n" + diff --git a/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java b/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java index 79ffe859..63b454a0 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java +++ b/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java @@ -149,6 +149,7 @@ public class SettingsService { private static final String KEY_SMTP_PORT = "SmtpPort"; private static final String KEY_SMTP_USER = "SmtpUser"; private static final String KEY_SMTP_PASSWORD = "SmtpPassword"; + private static final String KEY_SMTP_FROM = "SmtpFrom"; // Default values. private static final String DEFAULT_INDEX_STRING = "A B C D E F G H I J K L M N O P Q R S T U V W X-Z(XYZ)"; @@ -223,6 +224,7 @@ public class SettingsService { private static final String DEFAULT_SMTP_PORT = "25"; private static final String DEFAULT_SMTP_USER = null; private static final String DEFAULT_SMTP_PASSWORD = null; + private static final String DEFAULT_SMTP_FROM = "libresonic@libresonic.org"; // Array of obsolete keys. Used to clean property file. private static final List OBSOLETE_KEYS = Arrays.asList("PortForwardingPublicPort", "PortForwardingLocalPort", @@ -1508,4 +1510,12 @@ public class SettingsService { } properties.setProperty(KEY_SMTP_PASSWORD, smtpPassword); } + + public String getSmtpFrom() { + return properties.getProperty(KEY_SMTP_FROM, DEFAULT_SMTP_FROM); + } + + public void setSmtpFrom(String smtpFrom) { + setString(KEY_SMTP_FROM, smtpFrom); + } } diff --git a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties index 6fc2cae7..9664d4c3 100644 --- a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties +++ b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties @@ -343,12 +343,13 @@ advancedsettings.ldapmanagerpassword = Password advancedsettings.ldapautoshadowing = Automatically create users in {0} advancedsettings.smtpPort = SMTP port advancedsettings.smtpServer = SMTP server -advancedsettings.smtpEncryption = SMTP encryption method +advancedsettings.smtpEncryption = SMTP encryption advancedsettings.smtpUser = SMTP username -advancedsettings.smtpPassword = SMTP password +advancedsettings.smtpPassword = Password advancedsettings.smtpEncryption.none = None advancedsettings.smtpEncryption.starttls = STARTTLS advancedsettings.smtpEncryption.ssl = SSL/TLS +advancedsettings.smtpFrom = Mail sender # personalSettings.jsp personalsettings.title = Personal settings for {0} @@ -821,10 +822,12 @@ helppopup.smtpServer.text =

The hostname of the SMTP server. This server will who have requested a password reset.

helppopup.smtpPort.title = SMTP Port helppopup.smtpPort.text =

The server's port that should be connected to for SMTP traffic.

-helppopup.smtpUser.title = SMTP User -helppopup.smtpUser.text =

The username to be used to authenticate with the server. Leave empty to connect without authentication.

+helppopup.smtpCredentials.title = SMTP Credentials +helppopup.smtpCredentials.text =

The credentials to be used to connect to the SMTP server. Leave empty to connect without authentication.

helppopup.smtpEncryption.title = SMTP Encryption helppopup.smtpEncryption.text =

The encryption method to be used to connect to the SMTP server. Choose "None" for no encryption.

+helppopup.smtpFrom.title = From address +helppopup.smtpFrom.text =

The sender address for mails originating from the Libresonic server. Must be a valid e-mail address.

# wap/index.jsp wap.index.missing = No music found diff --git a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_nl.properties b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_nl.properties index 2dae8742..b571bab8 100644 --- a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_nl.properties +++ b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_nl.properties @@ -343,8 +343,9 @@ advancedsettings.smtpPort = SMTP poort advancedsettings.smtpServer = SMTP server advancedsettings.smtpEncryption = SMTP versleutelingsmethode advancedsettings.smtpUser = SMTP gebruikersnaam -advancedsettings.smtpPassword = SMTP wachtwoord +advancedsettings.smtpPassword = Wachtwoord advancedsettings.smtpEncryption.none = Geen +advancedsettings.smtpFrom = Afzender # personalsettings.jsp personalsettings.title = Persoonlijke instellingen voor {0} diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp index d12c1975..69291892 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp @@ -41,7 +41,15 @@ - +
+ + + + + - - - - -
+ + +
@@ -61,7 +69,7 @@
- + @@ -77,15 +85,10 @@
- - -
- + + + +