mirror of
https://github.com/neilalexander/yggmail.git
synced 2026-05-02 01:56:28 +03:00
Lint in CI
This commit is contained in:
@@ -31,7 +31,7 @@ func (b *Backend) Login(conn *imap.ConnInfo, username, password string) (backend
|
||||
// If our username is email-like, then take just the localpart
|
||||
if pk, err := utils.ParseAddress(username); err == nil {
|
||||
if !pk.Equal(b.Config.PublicKey) {
|
||||
b.Log.Println("Failed to authenticate IMAP user due to wrong domain", pk, b.Config.PublicKey)
|
||||
b.Log.Println("Failed to authenticate IMAP user due to wrong domain", hex.EncodeToString(pk), hex.EncodeToString(b.Config.PublicKey))
|
||||
return nil, fmt.Errorf("failed to authenticate: wrong domain in username")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,7 +327,9 @@ func (mbox *Mailbox) MoveMessages(uid bool, seqset *imap.SeqSet, dest string) er
|
||||
return err
|
||||
}
|
||||
if mbox.name == "Outbox" {
|
||||
mbox.backend.Storage.QueueDeleteDestinationForID("Outbox", int(id))
|
||||
if err := mbox.backend.Storage.QueueDeleteDestinationForID("Outbox", int(id)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -120,7 +120,9 @@ func (q *Queue) run() {
|
||||
_, mail, err := q.queues.Storage.MailSelect("Outbox", ref.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
q.queues.Storage.QueueDeleteDestinationForID("Outbox", ref.ID)
|
||||
if err = q.queues.Storage.QueueDeleteDestinationForID("Outbox", ref.ID); err != nil {
|
||||
q.queues.Log.Println("Failed delete queue destination for ID", ref.ID, "due to error:", err)
|
||||
}
|
||||
} else {
|
||||
q.queues.Log.Println("Failed to get mail", ref.ID, "due to error:", err)
|
||||
}
|
||||
@@ -134,13 +136,13 @@ func (q *Queue) run() {
|
||||
if err != nil {
|
||||
return fmt.Errorf("q.queues.Transport.Dial: %w", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
defer conn.Close() // nolint:errcheck
|
||||
|
||||
client, err := smtp.NewClient(conn, q.destination)
|
||||
if err != nil {
|
||||
return fmt.Errorf("smtp.NewClient: %w", err)
|
||||
}
|
||||
defer client.Close()
|
||||
defer client.Close() // nolint:errcheck
|
||||
|
||||
if err := client.Hello(hex.EncodeToString(q.queues.Config.PublicKey)); err != nil {
|
||||
q.queues.Log.Println("Remote server", q.destination, "did not accept HELLO:", err)
|
||||
@@ -161,7 +163,7 @@ func (q *Queue) run() {
|
||||
if err != nil {
|
||||
return fmt.Errorf("client.Data: %w", err)
|
||||
}
|
||||
defer writer.Close()
|
||||
defer writer.Close() // nolint:errcheck
|
||||
|
||||
if _, err := writer.Write(mail.Mail); err != nil {
|
||||
return fmt.Errorf("writer.Write: %w", err)
|
||||
|
||||
@@ -62,16 +62,16 @@ func (b *Backend) Login(state *smtp.ConnectionState, username, password string)
|
||||
}, nil
|
||||
|
||||
case BackendModeExternal:
|
||||
return nil, fmt.Errorf("Not expecting authenticated connection on external backend")
|
||||
return nil, fmt.Errorf("not expecting authenticated connection on external backend")
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("Authenticated login failed")
|
||||
return nil, fmt.Errorf("authenticated login failed")
|
||||
}
|
||||
|
||||
func (b *Backend) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, error) {
|
||||
switch b.Mode {
|
||||
case BackendModeInternal:
|
||||
return nil, fmt.Errorf("Not expecting anonymous connection on internal backend")
|
||||
return nil, fmt.Errorf("not expecting anonymous connection on internal backend")
|
||||
|
||||
case BackendModeExternal:
|
||||
// The connection came from our overlay listener, so we should check
|
||||
@@ -82,7 +82,7 @@ func (b *Backend) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, err
|
||||
}
|
||||
remote := hex.EncodeToString(pks)
|
||||
if state.Hostname != remote {
|
||||
return nil, fmt.Errorf("You are not who you claim to be")
|
||||
return nil, fmt.Errorf("you are not who you claim to be")
|
||||
}
|
||||
|
||||
b.Log.Println("Incoming SMTP session from", remote)
|
||||
@@ -93,5 +93,5 @@ func (b *Backend) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, err
|
||||
}, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("Anonymous login failed")
|
||||
return nil, fmt.Errorf("anonymous login failed")
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (w *Writer) Do(db *sql.DB, txn *sql.Tx, f func(txn *sql.Tx) error) error {
|
||||
}
|
||||
|
||||
func (w *Writer) run() {
|
||||
if !w.running.CAS(false, true) {
|
||||
if !w.running.CompareAndSwap(false, true) {
|
||||
return
|
||||
}
|
||||
defer w.running.Store(false)
|
||||
|
||||
@@ -110,7 +110,7 @@ func (t *TableMailboxes) MailboxList(onlySubscribed bool) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("t.listMailboxes.Query: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
defer rows.Close() // nolint:errcheck
|
||||
var mailboxes []string
|
||||
for rows.Next() {
|
||||
var mailbox string
|
||||
|
||||
@@ -200,7 +200,7 @@ func (t *TableMails) MailSearch(mailbox string) ([]uint32, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("t.searchMail.Query: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
defer rows.Close() // nolint:errcheck
|
||||
for rows.Next() {
|
||||
var id uint32
|
||||
if err := rows.Scan(&id); err != nil {
|
||||
|
||||
@@ -98,7 +98,7 @@ func (t *TableQueue) QueueListDestinations() ([]string, error) {
|
||||
}
|
||||
return nil, fmt.Errorf("t.queueSelectDestinations.Query: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
defer rows.Close() // nolint:errcheck
|
||||
var destinations []string
|
||||
for rows.Next() {
|
||||
var destination string
|
||||
@@ -118,7 +118,7 @@ func (t *TableQueue) QueueMailIDsForDestination(destination string) ([]types.Que
|
||||
}
|
||||
return nil, fmt.Errorf("t.queueSelectDestinations.Query: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
defer rows.Close() // nolint:errcheck
|
||||
var ids []types.QueuedMail
|
||||
for rows.Next() {
|
||||
var id int
|
||||
|
||||
Reference in New Issue
Block a user