aboutsummaryrefslogtreecommitdiffstats
path: root/lib/address.go
diff options
context:
space:
mode:
authorBen Burwell <ben@benburwell.com>2019-07-07 22:43:58 -0400
committerDrew DeVault <sir@cmpwn.com>2019-07-08 16:06:28 -0400
commitc610c3cd9dd47c400e52c1858e987f5f32a7a45b (patch)
tree6e521ba706d87ea4a03ce81d57ff84317506f3df /lib/address.go
parent88c379dcbaaf9fd549cd271817e79fe634b1dd84 (diff)
downloadaerc-c610c3cd9dd47c400e52c1858e987f5f32a7a45b.tar.gz
Factor IMAP-specific structs out of UI models
Before, we were using several IMAP-specific concepts to represent information being displayed in the UI. Factor these structures out of the IMAP package to make it easier for other backends to provide the required information.
Diffstat (limited to 'lib/address.go')
-rw-r--r--lib/address.go40
1 files changed, 0 insertions, 40 deletions
diff --git a/lib/address.go b/lib/address.go
deleted file mode 100644
index b557195b..00000000
--- a/lib/address.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package lib
-
-import (
- "bytes"
- "fmt"
- "regexp"
- "strings"
-
- "github.com/emersion/go-imap"
-)
-
-var (
- atom *regexp.Regexp = regexp.MustCompile("^[a-z0-9!#$%7'*+-/=?^_`{}|~ ]+$")
-)
-
-func FormatAddresses(addrs []*imap.Address) string {
- val := bytes.Buffer{}
- for i, addr := range addrs {
- val.WriteString(FormatAddress(addr))
- if i != len(addrs)-1 {
- val.WriteString(", ")
- }
- }
- return val.String()
-}
-
-func FormatAddress(addr *imap.Address) string {
- if addr.PersonalName != "" {
- if atom.MatchString(addr.PersonalName) {
- return fmt.Sprintf("%s <%s@%s>",
- addr.PersonalName, addr.MailboxName, addr.HostName)
- } else {
- return fmt.Sprintf("\"%s\" <%s@%s>",
- strings.ReplaceAll(addr.PersonalName, "\"", "'"),
- addr.MailboxName, addr.HostName)
- }
- } else {
- return fmt.Sprintf("<%s@%s>", addr.MailboxName, addr.HostName)
- }
-}