diff options
Diffstat (limited to 'lib/ipc/receive.go')
-rw-r--r-- | lib/ipc/receive.go | 46 |
1 files changed, 5 insertions, 41 deletions
diff --git a/lib/ipc/receive.go b/lib/ipc/receive.go index 4f6258ad..ff837d0f 100644 --- a/lib/ipc/receive.go +++ b/lib/ipc/receive.go @@ -5,14 +5,10 @@ import ( "context" "errors" "net" - "net/url" "os" - "strings" "sync/atomic" "time" - "git.sr.ht/~rjarry/go-opt" - "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib/log" "git.sr.ht/~rjarry/aerc/lib/xdg" @@ -101,44 +97,12 @@ func (as *AercServer) Serve() { } func (as *AercServer) handleMessage(req *Request) *Response { - if len(req.Arguments) == 0 { - return &Response{} // send noop success message, i.e. ping + if config.General.DisableIPC { + return &Response{Error: "command rejected: IPC is disabled"} } - var err error - switch { - case strings.HasPrefix(req.Arguments[0], "mailto:"): - mailto, err := url.Parse(req.Arguments[0]) - if err != nil { - return &Response{Error: err.Error()} - } - err = as.handler.Mailto(mailto) - if err != nil { - return &Response{ - Error: err.Error(), - } - } - case strings.HasPrefix(req.Arguments[0], "mbox:"): - err = as.handler.Mbox(req.Arguments[0]) - if err != nil { - return &Response{Error: err.Error()} - } - case strings.HasPrefix(req.Arguments[0], ":"): - if config.General.DisableIPC { - return &Response{ - Error: "command rejected: IPC is disabled", - } - } - cmdline := req.Arguments[0] - if len(req.Arguments) > 1 { - cmdline = opt.QuoteArgs(req.Arguments...).String() - } - err = as.handler.Command(cmdline) - if err != nil { - return &Response{Error: err.Error()} - } - - default: - return &Response{Error: "command not understood"} + err := as.handler.Command(req.Arguments) + if err != nil { + return &Response{Error: err.Error()} } return &Response{} } |