aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-31 14:42:18 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-31 14:42:18 -0400
commit8e5ed2a161bf654888a8b48af2d9fdf6fbc0c7e0 (patch)
tree9a83cf70c8c7e1491005cfc1bab1d7e2e6cbe92d /widgets
parentf9262e4b0600fcc83ddac642412769c2bce05c5c (diff)
downloadaerc-8e5ed2a161bf654888a8b48af2d9fdf6fbc0c7e0.tar.gz
Implement header-regex-match filters
Diffstat (limited to 'widgets')
-rw-r--r--widgets/msgviewer.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 67fd0cc9..56c38974 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -117,8 +117,25 @@ func NewMessageViewer(conf *config.AercConfig, store *lib.MessageStore,
case config.FILTER_MIMETYPE:
if fnmatch.Match(f.Filter, mime, 0) {
filter = exec.Command(cmd[0], cmd[1:]...)
- fmt.Printf("Using filter for %s: %s\n", mime, f.Command)
}
+ case config.FILTER_HEADER:
+ var header string
+ switch f.Header {
+ case "subject":
+ header = msg.Envelope.Subject
+ case "from":
+ header = formatAddresses(msg.Envelope.From)
+ case "to":
+ header = formatAddresses(msg.Envelope.To)
+ case "cc":
+ header = formatAddresses(msg.Envelope.Cc)
+ }
+ if f.Regex.Match([]byte(header)) {
+ filter = exec.Command(cmd[0], cmd[1:]...)
+ }
+ }
+ if filter != nil {
+ break
}
}
if filter != nil {