aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex McGrath <amk@amk.ie>2022-05-07 09:17:12 +0100
committerSimon Ser <contact@emersion.fr>2022-05-07 10:18:59 +0200
commit7cb145748a4ef9a74a95cf0eaeace354950bfd32 (patch)
tree9ccf5b27106a5d7a17f0e5176cb9e8dc832685cd
parentf4523b51af0787795973b403b978ff74737a47ef (diff)
downloadalps-7cb145748a4ef9a74a95cf0eaeace354950bfd32.tar.gz
alps-7cb145748a4ef9a74a95cf0eaeace354950bfd32.zip
gracefully fail when no messages are selected for deletion or moving
-rw-r--r--plugins/base/routes.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go
index 255faa5..52d1681 100644
--- a/plugins/base/routes.go
+++ b/plugins/base/routes.go
@@ -1024,6 +1024,11 @@ func handleMove(ctx *alps.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, err)
}
+ if len(uids) == 0 {
+ ctx.Session.PutNotice("No messages selected.")
+ return ctx.Redirect(http.StatusFound, fmt.Sprintf("/mailbox/%v", url.PathEscape(mboxName)))
+ }
+
to := formOrQueryParam(ctx, "to")
if to == "" {
return echo.NewHTTPError(http.StatusBadRequest, "missing 'to' form parameter")
@@ -1071,6 +1076,11 @@ func handleDelete(ctx *alps.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, err)
}
+ if len(uids) == 0 {
+ ctx.Session.PutNotice("No messages selected.")
+ return ctx.Redirect(http.StatusFound, fmt.Sprintf("/mailbox/%v", url.PathEscape(mboxName)))
+ }
+
err = ctx.Session.DoIMAP(func(c *imapclient.Client) error {
if err := ensureMailboxSelected(c, mboxName); err != nil {
return err