Skip to content

Commit

Permalink
fix(ui-tweak): Automatically reconnect an account if log settings are…
Browse files Browse the repository at this point in the history
… updated via UI
  • Loading branch information
andris9 committed Mar 27, 2024
1 parent 3749f89 commit 4d4be15
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
17 changes: 16 additions & 1 deletion lib/routes-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6899,12 +6899,21 @@ ${Buffer.from(data.content, 'base64url').toString('base64')}
}
}

let logInfo = (await settings.get('logs')) || {
all: false,
maxLogLines: DEFAULT_MAX_LOG_LINES
};

if (!logInfo.maxLogLines) {
logInfo.maxLogLines = DEFAULT_MAX_LOG_LINES;
}

return h.view(
'accounts/account',
{
menuAccounts: true,
account: accountData,
logs: await settings.get('logs'),
logs: logInfo,
smtpError: accountData.smtpStatus && accountData.smtpStatus.status === 'error',

showSmtp: accountData.smtp || (accountData.oauth2 && accountData.oauth2.provider),
Expand Down Expand Up @@ -7087,6 +7096,12 @@ ${Buffer.from(data.content, 'base64url').toString('base64')}

await redis.hSetExists(accountObject.getAccountKey(), 'logs', request.payload.enabled ? 'true' : 'false');

try {
await call({ cmd: 'update', account });
} catch (err) {
request.logger.error({ msg: 'Reconnect request failed', action: 'request_reconnect', account, err });
}

return {
success: true,
enabled: (await redis.hget(accountObject.getAccountKey(), 'logs')) === 'true'
Expand Down
11 changes: 6 additions & 5 deletions views/accounts/account.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@
{{/if}}
</dd>

<dt class="col-sm-3">Recent logs</dt>
<dt class="col-sm-3">Recent logs <a href="#" tabindex="-1" role="button" data-toggle="popover"
data-trigger="hover" style="dispaly: inline-block;"
data-content="Up to last {{logs.maxLogLines}} log lines"><i
class="fas fa-info-circle text-info"></i></a>
</dt>

<dd class="col-sm-9">
{{#if logs.all}}
<div>
Expand All @@ -174,10 +179,6 @@
</div>

{{/if}}
<div>
<small>Logging is session based so account reconnect is required for logging changes to take into
effect</small>
</div>
</dd>
</dl>

Expand Down

0 comments on commit 4d4be15

Please sign in to comment.