Allow filtering emails via headers
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
@ -75,6 +76,16 @@ func createInboxQueryFromRequest(r *http.Request) (*query.GetInboxRequest, error
|
||||
}
|
||||
}
|
||||
|
||||
var headers map[string]string
|
||||
|
||||
rawHeaders := r.URL.Query().Get("headers")
|
||||
if rawHeaders != "" {
|
||||
headers = make(map[string]string)
|
||||
if err := json.Unmarshal([]byte(rawHeaders), &headers); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
|
||||
search := &query.InboxSearch{}
|
||||
if to != "" {
|
||||
search.To = to
|
||||
@ -96,6 +107,10 @@ func createInboxQueryFromRequest(r *http.Request) (*query.GetInboxRequest, error
|
||||
search.Before = before
|
||||
}
|
||||
|
||||
if rawHeaders != "" {
|
||||
search.Headers = headers
|
||||
}
|
||||
|
||||
inboxRequest := &query.GetInboxRequest{
|
||||
OrderBy: orderBy,
|
||||
Reverse: reverse == "y",
|
||||
|
Reference in New Issue
Block a user