when moving message to mailbox with special-use flag "Junk", mark the message as junk too, for retraining

i had been using the AutomaticJunkFlags option, so hadn't noticed the special use flag wasn't used.
This commit is contained in:
Mechiel Lukkien
2023-09-21 15:19:11 +02:00
parent 79774c15ec
commit 2e16d8025d
5 changed files with 13 additions and 8 deletions

View File

@ -611,12 +611,17 @@ func (m Message) NeedsTraining() bool {
// used when delivering/moving/copying messages to a mailbox. Mail clients are not
// very helpful with setting junk/notjunk flags. But clients can move/copy messages
// to other mailboxes. So we set flags when clients move a message.
func (m *Message) JunkFlagsForMailbox(mailbox string, conf config.Account) {
func (m *Message) JunkFlagsForMailbox(mb Mailbox, conf config.Account) {
if mb.Junk {
m.Junk = true
m.Notjunk = false
}
if !conf.AutomaticJunkFlags.Enabled {
return
}
lmailbox := strings.ToLower(mailbox)
lmailbox := strings.ToLower(mb.Name)
if conf.JunkMailbox != nil && conf.JunkMailbox.MatchString(lmailbox) {
m.Junk = true
@ -1220,7 +1225,7 @@ func (a *Account) DeliverMessage(log *mlog.Log, tx *bstore.Tx, m *Message, msgFi
}
conf, _ := a.Conf()
m.JunkFlagsForMailbox(mb.Name, conf)
m.JunkFlagsForMailbox(mb, conf)
mr := FileMsgReader(m.MsgPrefix, msgFile) // We don't close, it would close the msgFile.
var part *message.Part