From 9eac0b453a21918f7533e78aa0fbb4d07cdbf474 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 19 Mar 2020 17:25:52 +0100 Subject: plugins/base: allow to specify move/flag params via query --- plugins/base/routes.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'plugins/base') diff --git a/plugins/base/routes.go b/plugins/base/routes.go index d2bfe73..0782159 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -669,6 +669,12 @@ func handleMove(ctx *koushin.Context) error { } to := ctx.FormValue("to") + if to == "" { + to = ctx.QueryParam("to") + } + if to == "" { + return echo.NewHTTPError(http.StatusBadRequest, "missing 'to' form parameter") + } err = ctx.Session.DoIMAP(func(c *imapclient.Client) error { mc := imapmove.NewClient(c) @@ -751,17 +757,28 @@ func handleSetFlags(ctx *koushin.Context) error { if err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) } + uids, err := parseUidList(formParams["uids"]) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) } + flags, ok := formParams["flags"] if !ok { - return echo.NewHTTPError(http.StatusBadRequest, "missing 'flags' form values") + flagsStr := ctx.QueryParam("to") + if flagsStr == "" { + return echo.NewHTTPError(http.StatusBadRequest, "missing 'flags' form parameter") + } + flags = strings.Fields(flagsStr) + } + + actionStr := ctx.FormValue("action") + if actionStr == "" { + actionStr = ctx.QueryParam("action") } var op imap.FlagsOp - switch ctx.FormValue("action") { + switch actionStr { case "", "set": op = imap.SetFlags case "add": -- cgit v1.2.3