mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 08:23:48 +03:00
mox retrain: make the parameter, for account, optional and retrain all accounts when absent
for more easily retraining all accounts. users should be retraining their accounts with the next release, due to the fix in the previous commit.
This commit is contained in:
parent
17baf9a883
commit
94fb48c2dc
3 changed files with 74 additions and 59 deletions
15
ctl.go
15
ctl.go
|
@ -1335,11 +1335,13 @@ func servectlcmd(ctx context.Context, ctl *ctl, shutdown func()) {
|
||||||
case "retrain":
|
case "retrain":
|
||||||
/* protocol:
|
/* protocol:
|
||||||
> "retrain"
|
> "retrain"
|
||||||
> account
|
> account or empty
|
||||||
< "ok" or error
|
< "ok" or error
|
||||||
*/
|
*/
|
||||||
account := ctl.xread()
|
account := ctl.xread()
|
||||||
acc, err := store.OpenAccount(log, account)
|
|
||||||
|
xretrain := func(name string) {
|
||||||
|
acc, err := store.OpenAccount(log, name)
|
||||||
ctl.xcheck(err, "open account")
|
ctl.xcheck(err, "open account")
|
||||||
defer func() {
|
defer func() {
|
||||||
if acc != nil {
|
if acc != nil {
|
||||||
|
@ -1396,6 +1398,15 @@ func servectlcmd(ctx context.Context, ctl *ctl, shutdown func()) {
|
||||||
jf = nil
|
jf = nil
|
||||||
ctl.xcheck(err, "closing junk filter")
|
ctl.xcheck(err, "closing junk filter")
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if account == "" {
|
||||||
|
for _, name := range mox.Conf.Accounts() {
|
||||||
|
xretrain(name)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
xretrain(account)
|
||||||
|
}
|
||||||
ctl.xwriteok()
|
ctl.xwriteok()
|
||||||
|
|
||||||
case "recalculatemailboxcounts":
|
case "recalculatemailboxcounts":
|
||||||
|
|
6
doc.go
6
doc.go
|
@ -105,7 +105,7 @@ any parameters. Followed by the help and usage information for each command.
|
||||||
mox dnsbl check zone ip
|
mox dnsbl check zone ip
|
||||||
mox dnsbl checkhealth zone
|
mox dnsbl checkhealth zone
|
||||||
mox mtasts lookup domain
|
mox mtasts lookup domain
|
||||||
mox retrain accountname
|
mox retrain [accountname]
|
||||||
mox sendmail [-Fname] [ignoredflags] [-t] [<message]
|
mox sendmail [-Fname] [ignoredflags] [-t] [<message]
|
||||||
mox spf check domain ip
|
mox spf check domain ip
|
||||||
mox spf lookup domain
|
mox spf lookup domain
|
||||||
|
@ -1390,12 +1390,12 @@ should be used, and how long the policy can be cached.
|
||||||
|
|
||||||
# mox retrain
|
# mox retrain
|
||||||
|
|
||||||
Recreate and retrain the junk filter for the account.
|
Recreate and retrain the junk filter for the account or all accounts.
|
||||||
|
|
||||||
Useful after having made changes to the junk filter configuration, or if the
|
Useful after having made changes to the junk filter configuration, or if the
|
||||||
implementation has changed.
|
implementation has changed.
|
||||||
|
|
||||||
usage: mox retrain accountname
|
usage: mox retrain [accountname]
|
||||||
|
|
||||||
# mox sendmail
|
# mox sendmail
|
||||||
|
|
||||||
|
|
12
main.go
12
main.go
|
@ -2874,19 +2874,23 @@ should be used, and how long the policy can be cached.
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdRetrain(c *cmd) {
|
func cmdRetrain(c *cmd) {
|
||||||
c.params = "accountname"
|
c.params = "[accountname]"
|
||||||
c.help = `Recreate and retrain the junk filter for the account.
|
c.help = `Recreate and retrain the junk filter for the account or all accounts.
|
||||||
|
|
||||||
Useful after having made changes to the junk filter configuration, or if the
|
Useful after having made changes to the junk filter configuration, or if the
|
||||||
implementation has changed.
|
implementation has changed.
|
||||||
`
|
`
|
||||||
args := c.Parse()
|
args := c.Parse()
|
||||||
if len(args) != 1 {
|
if len(args) > 1 {
|
||||||
c.Usage()
|
c.Usage()
|
||||||
}
|
}
|
||||||
|
var account string
|
||||||
|
if len(args) == 1 {
|
||||||
|
account = args[0]
|
||||||
|
}
|
||||||
|
|
||||||
mustLoadConfig()
|
mustLoadConfig()
|
||||||
ctlcmdRetrain(xctl(), args[0])
|
ctlcmdRetrain(xctl(), account)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ctlcmdRetrain(ctl *ctl, account string) {
|
func ctlcmdRetrain(ctl *ctl, account string) {
|
||||||
|
|
Loading…
Reference in a new issue