Very early NOTIFY support, hopefully fix -password on Windows

This commit is contained in:
Neil Alexander
2021-07-10 11:42:55 +01:00
parent 4c07013a13
commit 63de5e81e4
8 changed files with 141 additions and 31 deletions

View File

@@ -65,10 +65,17 @@ func (s *SessionRemote) Data(r io.Reader) error {
return fmt.Errorf("m.WriteTo: %w", err)
}
if _, err := s.backend.Storage.MailCreate("INBOX", b.Bytes()); err != nil {
if id, err := s.backend.Storage.MailCreate("INBOX", b.Bytes()); err != nil {
return fmt.Errorf("s.backend.Storage.StoreMessageFor: %w", err)
} else {
s.backend.Log.Printf("Stored new mail from %s", s.from)
if count, err := s.backend.Storage.MailCount("INBOX"); err == nil {
if err := s.backend.Notify.NotifyNew(id, count); err != nil {
s.backend.Log.Println("Failed to notify:", s.from)
}
}
}
s.backend.Log.Printf("Stored new mail from %s", s.from)
return nil
}