diff options
Diffstat (limited to 'plugins/base')
-rw-r--r-- | plugins/base/routes.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go index c031cb0..ecdfc1a 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -34,6 +34,9 @@ func registerRoutes(p *alps.GoPlugin) { p.GET("/new-mailbox", handleNewMailbox) p.POST("/new-mailbox", handleNewMailbox) + p.GET("/delete-mailbox/:mbox", handleDeleteMailbox) + p.POST("/delete-mailbox/:mbox", handleDeleteMailbox) + p.GET("/message/:mbox/:uid", func(ctx *alps.Context) error { return handleGetPart(ctx, false) }) @@ -303,6 +306,25 @@ func handleNewMailbox(ctx *alps.Context) error { }) } +func handleDeleteMailbox(ctx *alps.Context) error { + ibase, err := newIMAPBaseRenderData(ctx, alps.NewBaseRenderData(ctx)) + if err != nil { + return err + } + + mbox := ibase.Mailbox + ibase.BaseRenderData.WithTitle("Delete folder '" + mbox.Name + "'") + + if ctx.Request().Method == http.MethodPost { + ctx.Session.DoIMAP(func(c *imapclient.Client) error { + return c.Delete(mbox.Name) + }) + return ctx.Redirect(http.StatusFound, "/mailbox/INBOX") + } + + return ctx.Render(http.StatusOK, "delete-mailbox.html", ibase) +} + func handleLogin(ctx *alps.Context) error { username := ctx.FormValue("username") password := ctx.FormValue("password") |