summary refs log tree commit diff stats
path: root/widgets/msgviewer.go
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/msgviewer.go
parentf9262e4b0600fcc83ddac642412769c2bce05c5c (diff)
downloadaerc-8e5ed2a161bf654888a8b48af2d9fdf6fbc0c7e0.tar.gz
Implement header-regex-match filters
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r--widgets/msgviewer.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 67fd0cc..56c3897 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 {
pre>5d3fd37 ^
bba044d ^
05a618b ^

1076f2b
650a1fb ^
1076f2b
8b59083 ^
1076f2b

4d55eee ^
bba044d ^
dbf7e03 ^

4d55eee ^






dbf7e03 ^

4d55eee ^
dbf7e03 ^
4d55eee ^


dbf7e03 ^
4d55eee ^

dbf7e03 ^

4d55eee ^



dc5c070 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62