aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg/invite.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-12-20 20:29:12 +0100
committerRobin Jarry <robin@jarry.cc>2023-01-04 22:57:31 +0100
commit37e9a924894db7e5f232e82066155a60827c339b (patch)
tree48deeeea33113bbc9e6fcbcb8973a3ba1d62a06d /commands/msg/invite.go
parentc56027b2e69ec198e41394e5cf906273d80baf79 (diff)
downloadaerc-37e9a924894db7e5f232e82066155a60827c339b.tar.gz
config: parse account from and aliases once
Instead of accepting any garbage for these configuration fields, parse them when parsing accounts.conf and store mail.Address objects. Reuse these objects everywhere. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'commands/msg/invite.go')
-rw-r--r--commands/msg/invite.go16
1 files changed, 3 insertions, 13 deletions
diff --git a/commands/msg/invite.go b/commands/msg/invite.go
index 2dca259b..ef28b91c 100644
--- a/commands/msg/invite.go
+++ b/commands/msg/invite.go
@@ -62,20 +62,10 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error {
}
conf := acct.AccountConfig()
- from, err := mail.ParseAddress(conf.From)
- if err != nil {
- return err
- }
- var aliases []*mail.Address
- if conf.Aliases != "" {
- aliases, err = mail.ParseAddressList(conf.Aliases)
- if err != nil {
- return err
- }
- }
+ from := conf.From
// figure out the sending from address if we have aliases
- if len(aliases) != 0 {
+ if len(conf.Aliases) != 0 {
rec := newAddrSet()
rec.AddList(msg.Envelope.To)
rec.AddList(msg.Envelope.Cc)
@@ -83,7 +73,7 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error {
if rec.Contains(from) {
// do nothing
} else {
- for _, a := range aliases {
+ for _, a := range conf.Aliases {
if rec.Contains(a) {
from = a
break