From 96d5b4e149dccfdb75d41785e6525b647925f8ce Mon Sep 17 00:00:00 2001 From: Julian Marcos Date: Mon, 17 Apr 2023 06:22:11 +0200 Subject: search: handle headers in search/filter query Handle headers in the search and filter commands, for searching and filtering based on the Headers specified by the -H parameter, the syntax for the -H parameter should be `Header: Key`. Signed-off-by: Julian Marcos Acked-by: Robin Jarry --- worker/imap/search.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'worker/imap') diff --git a/worker/imap/search.go b/worker/imap/search.go index ba7b9174..77a18990 100644 --- a/worker/imap/search.go +++ b/worker/imap/search.go @@ -38,7 +38,13 @@ func parseSearch(args []string) (*imap.SearchCriteria, error) { criteria.WithoutFlags = append(criteria.WithoutFlags, f) } case 'H': - // TODO + if strings.Contains(opt.Value, ": ") { + HeaderValue := strings.SplitN(opt.Value, ": ", 2) + criteria.Header.Add(HeaderValue[0], HeaderValue[1]) + } else { + log.Errorf("Header is not given properly, must be given in format `Header: Value`") + continue + } case 'f': criteria.Header.Add("From", opt.Value) case 't': -- cgit