mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
32 lines
646 B
Go
32 lines
646 B
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package sender
|
|
|
|
import (
|
|
"errors"
|
|
"io"
|
|
)
|
|
|
|
type Sender interface {
|
|
Send(from string, to []string, msg io.WriterTo) error
|
|
}
|
|
|
|
var Send = send
|
|
|
|
func send(sender Sender, msg *Message) error {
|
|
m := msg.ToMessage()
|
|
froms := m.GetFrom()
|
|
to, err := m.GetRecipients()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// TODO: implement sending from multiple addresses
|
|
if len(froms) == 0 {
|
|
// FIXME: no idea why sometimes the "froms" can be empty, need to figure out the root problem
|
|
return errors.New("no FROM specified")
|
|
}
|
|
return sender.Send(froms[0].Address, to, m)
|
|
}
|