Add support for STARTTLS for Inbox Scanning (#682)

This commit is contained in:
Mario Voigt 2023-04-25 18:27:46 +02:00 committed by GitHub
parent dd36e08d7d
commit bd0cde7e87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 22 additions and 2 deletions

View File

@ -40,6 +40,7 @@ public enum ConfigType {
INBOX_ENABLED,
INBOX_HOSTNAME,
INBOX_PORT,
INBOX_STARTTLS,
INBOX_USERNAME,
INBOX_PASSWORD,
INBOX_FOLDER,

View File

@ -159,6 +159,7 @@ public class InboxService extends AbstractScheduledService {
String port = ConfigUtil.getConfigStringValue(ConfigType.INBOX_PORT);
properties.put("mail.imap.host", ConfigUtil.getConfigStringValue(ConfigType.INBOX_HOSTNAME));
properties.put("mail.imap.port", port);
properties.setProperty("mail.imap.starttls.enable", ConfigUtil.getConfigStringValue(ConfigType.INBOX_STARTTLS).toString());
boolean isSsl = "993".equals(port);
properties.put("mail.imap.ssl.enable", String.valueOf(isSsl));
properties.setProperty("mail.imap.socketFactory.class",

View File

@ -1 +1 @@
db.version=27
db.version=28

View File

@ -0,0 +1,2 @@
insert into T_CONFIG(CFG_ID_C, CFG_VALUE_C) values('INBOX_STARTTLS', 'false');
update T_CONFIG set CFG_VALUE_C = '28' where CFG_ID_C = 'DB_VERSION';

View File

@ -1,3 +1,3 @@
api.current_version=${project.version}
api.min_version=1.0
db.version=27
db.version=28

View File

@ -334,6 +334,7 @@ public class AppResource extends BaseResource {
Boolean deleteImported = ConfigUtil.getConfigBooleanValue(ConfigType.INBOX_DELETE_IMPORTED);
Config hostnameConfig = configDao.getById(ConfigType.INBOX_HOSTNAME);
Config portConfig = configDao.getById(ConfigType.INBOX_PORT);
Boolean starttls = ConfigUtil.getConfigBooleanValue(ConfigType.INBOX_STARTTLS);
Config usernameConfig = configDao.getById(ConfigType.INBOX_USERNAME);
Config passwordConfig = configDao.getById(ConfigType.INBOX_PASSWORD);
Config folderConfig = configDao.getById(ConfigType.INBOX_FOLDER);
@ -353,6 +354,7 @@ public class AppResource extends BaseResource {
} else {
response.add("port", Integer.valueOf(portConfig.getValue()));
}
response.add("starttls", starttls);
if (usernameConfig == null) {
response.addNull("username");
} else {
@ -425,6 +427,7 @@ public class AppResource extends BaseResource {
@FormParam("deleteImported") Boolean deleteImported,
@FormParam("hostname") String hostname,
@FormParam("port") String portStr,
@FormParam("starttls") Boolean starttls,
@FormParam("username") String username,
@FormParam("password") String password,
@FormParam("folder") String folder,
@ -439,6 +442,7 @@ public class AppResource extends BaseResource {
if (!Strings.isNullOrEmpty(portStr)) {
ValidationUtil.validateInteger(portStr, "port");
}
ValidationUtil.validateRequired(starttls, "starttls");
// Just update the changed configuration
ConfigDao configDao = new ConfigDao();
@ -451,6 +455,7 @@ public class AppResource extends BaseResource {
if (!Strings.isNullOrEmpty(portStr)) {
configDao.update(ConfigType.INBOX_PORT, portStr);
}
configDao.update(ConfigType.INBOX_STARTTLS, starttls.toString());
if (!Strings.isNullOrEmpty(username)) {
configDao.update(ConfigType.INBOX_USERNAME, username);
}

View File

@ -440,6 +440,7 @@
"enabled": "Durchsuchen des Posteingangs aktivieren",
"hostname": "IMAP-Server",
"port": "IMAP-Port (143 oder 993)",
"starttls": "Verwende STARTTLS",
"username": "IMAP-Benutzername",
"password": "IMAP-Passwort",
"folder": "IMAP-Ordner",
@ -449,6 +450,8 @@
"test_success": "Die Verbindung zum Posteingang war erfolgreich ({{ count }} <strong>ungelesene</strong> {{ count > 1 ? 'Nachrichten' : 'Nachricht' }})",
"test_fail": "Beim Verbinden mit dem Posteingang ist ein Fehler aufgetreten, bitte überprüfen Sie die Einstellungen",
"saved": "IMAP-Konfiguration erfolgreich gespeichert"
"autoTagsEnabled": "Automatisches Hinzufügen von Tags aus der mit # markierten Betreffzeile",
"deleteImported": "Importierte Nachrichten aus Mailbox löschen"
},
"monitoring": {
"background_tasks": "Hintergrundaufgaben",

View File

@ -440,6 +440,7 @@
"enabled": "Enable inbox scanning",
"hostname": "IMAP hostname",
"port": "IMAP port (143 or 993)",
"starttls": "Enable STARTTLS",
"username": "IMAP username",
"password": "IMAP password",
"folder": "IMAP folder",

View File

@ -45,6 +45,13 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="inboxStarttls">{{ 'settings.inbox.starttls' | translate }}</label>
<div class="col-sm-7">
<input name="starttls" type="checkbox" id="inboxStarttls" ng-model="inbox.starttls" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="inboxUsername">{{ 'settings.inbox.username' | translate }}</label>
<div class="col-sm-7">