make more account config fields configurable through web interface

so users can change it themselves, instead of requiring an admin to change the
settings.
This commit is contained in:
Mechiel Lukkien
2024-04-17 21:30:54 +02:00
parent 8bcce40c55
commit baf4df55a6
8 changed files with 223 additions and 13 deletions

View File

@ -302,6 +302,16 @@ const index = async () => {
let password2: HTMLInputElement
let passwordHint: HTMLElement
let autoJunkFlagsFieldset: HTMLFieldSetElement
let autoJunkFlagsEnabled: HTMLInputElement
let junkMailboxRegexp: HTMLInputElement
let neutralMailboxRegexp: HTMLInputElement
let notJunkMailboxRegexp: HTMLInputElement
let rejectsFieldset: HTMLFieldSetElement
let rejectsMailbox: HTMLInputElement
let keepRejects: HTMLInputElement
let outgoingWebhookFieldset: HTMLFieldSetElement
let outgoingWebhookURL: HTMLInputElement
let outgoingWebhookAuthorization: HTMLInputElement
@ -829,6 +839,65 @@ const index = async () => {
'%).',
] : [', no explicit limit is configured.']),
dom.h2('Automatic junk flags', attr.title('For the junk filter to work properly, it needs to be trained: Messages need to be marked as junk or nonjunk. Not all email clients help you set those flags. Automatic junk flags set the junk or nonjunk flags when messages are moved/copied to mailboxes matching configured regular expressions.')),
dom.form(
async function submit(e: SubmitEvent) {
e.preventDefault()
e.stopPropagation()
await check(autoJunkFlagsFieldset, client.AutomaticJunkFlagsSave(autoJunkFlagsEnabled.checked, junkMailboxRegexp.value, neutralMailboxRegexp.value, notJunkMailboxRegexp.value))
},
autoJunkFlagsFieldset=dom.fieldset(
dom.div(style({display: 'flex', gap: '1em'}),
dom.label(
'Enabled',
attr.title("If enabled, junk/nonjunk flags will be set automatically if they match a regular expression below. When two of the three mailbox regular expressions are set, the remaining one will match all unmatched messages. Messages are matched in order 'junk', 'neutral', 'not junk', and the search stops on the first match. Mailboxes are lowercased before matching."),
dom.div(autoJunkFlagsEnabled=dom.input(attr.type('checkbox'), acc.AutomaticJunkFlags.Enabled ? attr.checked('') : [])),
),
dom.label(
'Junk mailbox regexp',
dom.div(junkMailboxRegexp=dom.input(attr.value(acc.AutomaticJunkFlags.JunkMailboxRegexp))),
),
dom.label(
'Neutral mailbox regexp',
dom.div(neutralMailboxRegexp=dom.input(attr.value(acc.AutomaticJunkFlags.NeutralMailboxRegexp))),
),
dom.label(
'Not Junk mailbox regexp',
dom.div(notJunkMailboxRegexp=dom.input(attr.value(acc.AutomaticJunkFlags.NotJunkMailboxRegexp))),
),
dom.div(dom.span('\u00a0'), dom.div(dom.submitbutton('Save'))),
),
),
),
dom.br(),
dom.h2('Rejects'),
dom.form(
async function submit(e: SubmitEvent) {
e.preventDefault()
e.stopPropagation()
await check(rejectsFieldset, client.RejectsSave(rejectsMailbox.value, keepRejects.checked))
},
rejectsFieldset=dom.fieldset(
dom.div(style({display: 'flex', gap: '1em'}),
dom.label(
'Mailbox',
attr.title("Mail that looks like spam will be rejected, but a copy can be stored temporarily in a mailbox, e.g. Rejects. If mail isn't coming in when you expect, you can look there. The mail still isn't accepted, so the remote mail server may retry (hopefully, if legitimate), or give up (hopefully, if indeed a spammer). Messages are automatically removed from this mailbox, so do not set it to a mailbox that has messages you want to keep."),
dom.div(rejectsMailbox=dom.input(attr.value(acc.RejectsMailbox))),
),
dom.label(
"No cleanup",
attr.title("Don't automatically delete mail in the RejectsMailbox listed above. This can be useful, e.g. for future spam training. It can also cause storage to fill up."),
dom.div(keepRejects=dom.input(attr.type('checkbox'), acc.KeepRejects ? attr.checked('') : [])),
),
dom.div(dom.span('\u00a0'), dom.div(dom.submitbutton('Save'))),
),
),
),
dom.br(),
dom.h2('Webhooks'),
dom.h3('Outgoing', attr.title('Webhooks for outgoing messages are called for each attempt to deliver a message in the outgoing queue, e.g. when the queue has delivered a message to the next hop, when a single attempt failed with a temporary error, when delivery permanently failed, or when DSN (delivery status notification) messages were received about a previously sent message.')),
dom.form(