aboutsummaryrefslogtreecommitdiffstats
path: root/lib/state
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2023-10-12 10:38:39 -0400
committerRobin Jarry <robin@jarry.cc>2023-10-22 15:12:45 +0200
commit863e124e8437ac2f5a92fe3f291b7e7e022787fc (patch)
tree54aca238e0c622b6a34e4095830c45c264c0fabf /lib/state
parent8fdabbc4bfcaf8f0214a66777336a356cc2a0616 (diff)
downloadaerc-863e124e8437ac2f5a92fe3f291b7e7e022787fc.tar.gz
accounts: allow fnmatch-style wildcards in aliases
Wildcard aliases make it possible to always reply from the same address to which a message was addressed, which is useful for catch-all email domains. Support fnmatch-style wildcards in only the address portion of an alias. When replying to a message that matches a wildcard alias, substitute the matching email address for the wildcard address, but keep the name specified with the wildcard address. For example, when the alias "Someone Awesome" <*@someone.com> is present, the reply to an email addressed to "Someone" <hi@someone.com> would be from "Someone Awesome" <hi@someone.com>. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/state')
-rw-r--r--lib/state/templates.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/state/templates.go b/lib/state/templates.go
index 88c5eeae..92a25b72 100644
--- a/lib/state/templates.go
+++ b/lib/state/templates.go
@@ -8,6 +8,7 @@ import (
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib/parse"
"git.sr.ht/~rjarry/aerc/models"
+ "github.com/danwakefield/fnmatch"
sortthread "github.com/emersion/go-imap-sortthread"
"github.com/emersion/go-message/mail"
)
@@ -218,8 +219,10 @@ func (d *templateData) Peer() []*mail.Address {
to, _ = d.headers.AddressList("to")
}
for _, addr := range from {
- if d.myAddresses[addr.Address] {
- return to
+ for myAddr := range d.myAddresses {
+ if fnmatch.Match(myAddr, addr.Address, 0) {
+ return to
+ }
}
}
return from