aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/routes.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-10-30 15:21:33 -0400
committerDrew DeVault <sir@cmpwn.com>2020-10-30 15:21:33 -0400
commite4daf0778dc4682405017a7cbdc593808257408f (patch)
tree84628d405bcdf696636a9902d83201387ade4fda /plugins/base/routes.go
parent62e7cf89339ac585bdb72e78d90f0b468916436a (diff)
downloadalps-e4daf0778dc4682405017a7cbdc593808257408f.tar.gz
alps-e4daf0778dc4682405017a7cbdc593808257408f.zip
Implement mailbox deletion
Diffstat (limited to 'plugins/base/routes.go')
-rw-r--r--plugins/base/routes.go22
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")