summary refs log tree commit diff stats
path: root/models/models.go
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-11-10 19:57:09 +0100
committerReto Brunner <reto@labrat.space>2020-11-14 15:40:13 +0100
commitfc9ccc30008e564c1dea23b3bfe480ca5a10c070 (patch)
tree80acc77569557d73cbd073def0dabd6472653b5d /models/models.go
parentfb67d1f5a3f6fe875d74581aff59c79817a7b9f4 (diff)
downloadaerc-fc9ccc30008e564c1dea23b3bfe480ca5a10c070.tar.gz
remove models.Address in favor of go-message Address
We made a new type out of go-message/mail.Address without any real reason.
This suddenly made it necessary to convert from one to the other without actually
having any benefit whatsoever.
This commit gets rid of the additional type
Diffstat (limited to 'models/models.go')
-rw-r--r--models/models.go33
1 files changed, 5 insertions, 28 deletions
diff --git a/models/models.go b/models/models.go
index a93db72..bfe0ff3 100644
--- a/models/models.go
+++ b/models/models.go
@@ -3,9 +3,6 @@ package models
 import (
 	"fmt"
 	"io"
-	gomail "net/mail"
-	"regexp"
-	"strings"
 	"time"
 
 	"github.com/emersion/go-message/mail"
@@ -127,34 +124,14 @@ func (bs *BodyStructure) PartAtIndex(index []int) (*BodyStructure, error) {
 type Envelope struct {
 	Date      time.Time
 	Subject   string
-	From      []*Address
-	ReplyTo   []*Address
-	To        []*Address
-	Cc        []*Address
-	Bcc       []*Address
+	From      []*mail.Address
+	ReplyTo   []*mail.Address
+	To        []*mail.Address
+	Cc        []*mail.Address
+	Bcc       []*mail.Address
 	MessageId string
 }
 
-type Address gomail.Address
-
-var atom *regexp.Regexp = regexp.MustCompile("^[a-z0-9!#$%7'*+-/=?^_`{}|~ ]+$")
-
-// String formats the address. If the address's name
-// contains non-ASCII characters it will be quoted but not encoded.
-// Meant for display purposes to the humans, not for sending over the wire.
-func (a *Address) Format() string {
-	if a.Name != "" {
-		if atom.MatchString(a.Name) {
-			return fmt.Sprintf("%s <%s>", a.Name, a.Address)
-		} else {
-			return fmt.Sprintf("\"%s\" <%s>",
-				strings.ReplaceAll(a.Name, "\"", "'"), a.Address)
-		}
-	} else {
-		return fmt.Sprintf("<%s>", a.Address)
-	}
-}
-
 // OriginalMail is helper struct used for reply/forward
 type OriginalMail struct {
 	Date     time.Time