plugins/base: allow to specify move/flag params via query

This commit is contained in:
Simon Ser 2020-03-19 17:25:52 +01:00
parent b61e40f363
commit 9eac0b453a
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 19 additions and 2 deletions

View File

@ -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":