aboutsummaryrefslogtreecommitdiffstats
path: root/worker/lib
diff options
context:
space:
mode:
Diffstat (limited to 'worker/lib')
-rw-r--r--worker/lib/parse.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/worker/lib/parse.go b/worker/lib/parse.go
index d92eeda7..ad5e0a8b 100644
--- a/worker/lib/parse.go
+++ b/worker/lib/parse.go
@@ -104,7 +104,7 @@ func ParseEntityStructure(e *message.Entity) (*models.BodyStructure, error) {
if cd := e.Header.Get("content-disposition"); cd != "" {
contentDisposition, cdParams, err := e.Header.ContentDisposition()
if err != nil {
- return nil, fmt.Errorf("could not parse content disposition: %v", err)
+ return nil, fmt.Errorf("could not parse content disposition: %w", err)
}
body.Disposition = contentDisposition
body.DispositionParams = cdParams
@@ -113,7 +113,7 @@ func ParseEntityStructure(e *message.Entity) (*models.BodyStructure, error) {
if mpr := e.MultipartReader(); mpr != nil {
for {
part, err := mpr.NextPart()
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
return &body, nil
} else if err != nil {
return nil, err
@@ -133,27 +133,27 @@ var DateParseError = errors.New("date parsing failed")
func parseEnvelope(h *mail.Header) (*models.Envelope, error) {
from, err := parseAddressList(h, "from")
if err != nil {
- return nil, fmt.Errorf("could not read from address: %v", err)
+ return nil, fmt.Errorf("could not read from address: %w", err)
}
to, err := parseAddressList(h, "to")
if err != nil {
- return nil, fmt.Errorf("could not read to address: %v", err)
+ return nil, fmt.Errorf("could not read to address: %w", err)
}
cc, err := parseAddressList(h, "cc")
if err != nil {
- return nil, fmt.Errorf("could not read cc address: %v", err)
+ return nil, fmt.Errorf("could not read cc address: %w", err)
}
bcc, err := parseAddressList(h, "bcc")
if err != nil {
- return nil, fmt.Errorf("could not read bcc address: %v", err)
+ return nil, fmt.Errorf("could not read bcc address: %w", err)
}
replyTo, err := parseAddressList(h, "reply-to")
if err != nil {
- return nil, fmt.Errorf("could not read reply-to address: %v", err)
+ return nil, fmt.Errorf("could not read reply-to address: %w", err)
}
subj, err := h.Subject()
if err != nil {
- return nil, fmt.Errorf("could not read subject: %v", err)
+ return nil, fmt.Errorf("could not read subject: %w", err)
}
msgID, err := h.MessageID()
if err != nil {
@@ -167,7 +167,7 @@ func parseEnvelope(h *mail.Header) (*models.Envelope, error) {
if err != nil {
// still return a valid struct plus a sentinel date parsing error
// if only the date parsing failed
- err = fmt.Errorf("%w: %v", DateParseError, err)
+ err = fmt.Errorf("%v: %w", DateParseError, err)
}
return &models.Envelope{
Date: date,
@@ -217,7 +217,7 @@ func parseDate(h *mail.Header) (time.Time, error) {
func parseReceivedHeader(h *mail.Header) (time.Time, error) {
guess, err := h.Text("received")
if err != nil {
- return time.Time{}, fmt.Errorf("received header not parseable: %v",
+ return time.Time{}, fmt.Errorf("received header not parseable: %w",
err)
}
return time.Parse(time.RFC1123Z, dateRe.FindString(guess))
@@ -254,18 +254,18 @@ func MessageInfo(raw RawMessage) (*models.MessageInfo, error) {
defer r.Close()
msg, err := message.Read(r)
if err != nil {
- return nil, fmt.Errorf("could not read message: %v", err)
+ return nil, fmt.Errorf("could not read message: %w", err)
}
bs, err := ParseEntityStructure(msg)
if errors.As(err, new(message.UnknownEncodingError)) {
parseErr = err
} else if err != nil {
- return nil, fmt.Errorf("could not get structure: %v", err)
+ return nil, fmt.Errorf("could not get structure: %w", err)
}
h := &mail.Header{Header: msg.Header}
env, err := parseEnvelope(h)
if err != nil && !errors.Is(err, DateParseError) {
- return nil, fmt.Errorf("could not parse envelope: %v", err)
+ return nil, fmt.Errorf("could not parse envelope: %w", err)
// if only the date parsing failed we still get the rest of the
// envelop structure in a valid state.
// Date parsing errors are fairly common and it's better to be