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

@ -649,7 +649,7 @@ func (Account) FromIDLoginAddressesSave(ctx context.Context, loginAddresses []st
xcheckf(ctx, err, "saving account fromid login addresses")
}
// KeepRetiredPeriodsSave save periods to save retired messages and webhooks.
// KeepRetiredPeriodsSave saves periods to save retired messages and webhooks.
func (Account) KeepRetiredPeriodsSave(ctx context.Context, keepRetiredMessagePeriod, keepRetiredWebhookPeriod time.Duration) {
reqInfo := ctx.Value(requestInfoCtxKey).(requestInfo)
err := mox.AccountSave(ctx, reqInfo.AccountName, func(acc *config.Account) {
@ -661,3 +661,34 @@ func (Account) KeepRetiredPeriodsSave(ctx context.Context, keepRetiredMessagePer
}
xcheckf(ctx, err, "saving account keep retired periods")
}
// AutomaticJunkFlagsSave saves settings for automatically marking messages as
// junk/nonjunk when moved to mailboxes matching certain regular expressions.
func (Account) AutomaticJunkFlagsSave(ctx context.Context, enabled bool, junkRegexp, neutralRegexp, notJunkRegexp string) {
reqInfo := ctx.Value(requestInfoCtxKey).(requestInfo)
err := mox.AccountSave(ctx, reqInfo.AccountName, func(acc *config.Account) {
acc.AutomaticJunkFlags = config.AutomaticJunkFlags{
Enabled: enabled,
JunkMailboxRegexp: junkRegexp,
NeutralMailboxRegexp: neutralRegexp,
NotJunkMailboxRegexp: notJunkRegexp,
}
})
if err != nil && errors.Is(err, mox.ErrConfig) {
xcheckuserf(ctx, err, "saving account automatic junk flags")
}
xcheckf(ctx, err, "saving account automatic junk flags")
}
// RejectsSave saves the RejectsMailbox and KeepRejects settings.
func (Account) RejectsSave(ctx context.Context, mailbox string, keep bool) {
reqInfo := ctx.Value(requestInfoCtxKey).(requestInfo)
err := mox.AccountSave(ctx, reqInfo.AccountName, func(acc *config.Account) {
acc.RejectsMailbox = mailbox
acc.KeepRejects = keep
})
if err != nil && errors.Is(err, mox.ErrConfig) {
xcheckuserf(ctx, err, "saving account rejects settings")
}
xcheckf(ctx, err, "saving account rejects settings")
}