From 08b259bd50155c53259ae60042c8626a3615a993 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 16 Dec 2019 15:40:30 +0100 Subject: Add attachments support to composer Closes: https://todo.sr.ht/~sircmpwn/koushin/13 --- plugins/base/handlers.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugins/base/handlers.go') diff --git a/plugins/base/handlers.go b/plugins/base/handlers.go index 133052c..e939cc5 100644 --- a/plugins/base/handlers.go +++ b/plugins/base/handlers.go @@ -270,7 +270,13 @@ func handleCompose(ectx echo.Context) error { msg.Text = ctx.FormValue("text") msg.InReplyTo = ctx.FormValue("in_reply_to") - err := ctx.Session.DoSMTP(func(c *smtp.Client) error { + form, err := ctx.MultipartForm() + if err != nil { + return fmt.Errorf("failed to get multipart form: %v", err) + } + msg.Attachments = form.File["attachments"] + + err = ctx.Session.DoSMTP(func(c *smtp.Client) error { return sendMessage(c, &msg) }) if err != nil { -- cgit v1.2.3