diff options
author | Simon Ser <contact@emersion.fr> | 2020-03-19 17:25:52 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-03-19 17:25:52 +0100 |
commit | 9eac0b453a21918f7533e78aa0fbb4d07cdbf474 (patch) | |
tree | 6fee5667df786f17c3478817dec2878a207814c8 /plugins/base | |
parent | b61e40f36309e94541a6de3aff6d7356e9d7f99f (diff) | |
download | alps-9eac0b453a21918f7533e78aa0fbb4d07cdbf474.tar.gz alps-9eac0b453a21918f7533e78aa0fbb4d07cdbf474.zip |
plugins/base: allow to specify move/flag params via query
Diffstat (limited to 'plugins/base')
-rw-r--r-- | plugins/base/routes.go | 21 |
1 files changed, 19 insertions, 2 deletions
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": |