Skip to content

Commit

Permalink
fix(web-ui): Do not clear up IMAP settings when enabling/disabling IM…
Browse files Browse the repository at this point in the history
…AP in the web UI
  • Loading branch information
andris9 committed Apr 11, 2024
1 parent c97fc4a commit 037091b
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions lib/routes-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -7309,22 +7309,28 @@ ${Buffer.from(data.content, 'base64url').toString('base64')}
});

if (request.payload.imap) {
let imapAuth = Object.assign((oldData.imap && oldData.imap.auth) || {}, { user: request.payload.imap_auth_user });
let imapTls = (oldData.imap && oldData.imap.tls) || {};

if (request.payload.imap_auth_pass) {
imapAuth.pass = request.payload.imap_auth_pass;
let updateKeys = {
tls: imapTls
};

for (let key of ['host', 'port', 'disabled', 'sentMailPath']) {
if (`imap_${key}` in request.payload) {
updateKeys[key] = request.payload[`imap_${key}`];
}
}

updates.imap = Object.assign(oldData.imap || {}, {
host: request.payload.imap_host,
port: request.payload.imap_port,
secure: request.payload.imap_secure,
disabled: request.payload.imap_disabled,
sentMailPath: request.payload.imap_sentMailPath,
auth: imapAuth,
tls: imapTls
});
if ('imap_auth_user' in request.payload) {
let imapAuth = Object.assign((oldData.imap && oldData.imap.auth) || {}, { user: request.payload.imap_auth_user });
if (request.payload.imap_auth_pass) {
imapAuth.pass = request.payload.imap_auth_pass;
}
updateKeys.auth = imapAuth;
updateKeys.secure = request.payload.imap_secure;
}

updates.imap = Object.assign(oldData.imap || {}, updateKeys);

if (request.payload.imap_resyncDelay) {
updates.imap.resyncDelay = request.payload.imap_resyncDelay;
Expand Down

0 comments on commit 037091b

Please sign in to comment.