From a1e8bcc5619040ede66f7d53e6acf9df61870609 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 19 Nov 2020 11:35:57 -0500 Subject: Implement message signature setting --- plugins/base/routes.go | 16 +++++++++++++++- themes/alps/assets/style.css | 3 ++- themes/alps/settings.html | 16 +++++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/plugins/base/routes.go b/plugins/base/routes.go index 1562a15..f20097e 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -668,14 +668,23 @@ func handleCompose(ctx *alps.Context, msg *OutgoingMessage, options *composeOpti } func handleComposeNew(ctx *alps.Context) error { + text := ctx.QueryParam("body") + settings, err := loadSettings(ctx.Session.Store()) + if err != nil { + return nil + } + if text == "" && settings.Signature != "" { + text = "\n\n\n-- \n" + settings.Signature + } + // These are common mailto URL query parameters // TODO: cc, bcc return handleCompose(ctx, &OutgoingMessage{ To: strings.Split(ctx.QueryParam("to"), ","), Subject: ctx.QueryParam("subject"), - Text: ctx.QueryParam("body"), MessageID: mail.GenerateMessageID(), InReplyTo: ctx.QueryParam("in-reply-to"), + Text: text, }, &composeOptions{}) } @@ -1124,6 +1133,7 @@ const maxMessagesPerPage = 100 type Settings struct { MessagesPerPage int + Signature string } func loadSettings(s alps.Store) (*Settings, error) { @@ -1143,6 +1153,9 @@ func (s *Settings) check() error { if s.MessagesPerPage <= 0 || s.MessagesPerPage > maxMessagesPerPage { return fmt.Errorf("messages per page out of bounds: %v", s.MessagesPerPage) } + if len(s.Signature) > 2048 { + return fmt.Errorf("Signature must be 2048 characters or fewer") + } return nil } @@ -1162,6 +1175,7 @@ func handleSettings(ctx *alps.Context) error { if err != nil { return echo.NewHTTPError(http.StatusBadRequest, "invalid messages per page: %v", err) } + settings.Signature = ctx.FormValue("signature") if err := settings.check(); err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) diff --git a/themes/alps/assets/style.css b/themes/alps/assets/style.css index e4a0d35..e64c8a3 100644 --- a/themes/alps/assets/style.css +++ b/themes/alps/assets/style.css @@ -653,7 +653,8 @@ main table tfoot { } .action-group label, -.action-group input { +.action-group input, +.action-group textarea { display: block; width: 100%; } diff --git a/themes/alps/settings.html b/themes/alps/settings.html index f6e586b..ebcc532 100644 --- a/themes/alps/settings.html +++ b/themes/alps/settings.html @@ -3,12 +3,26 @@
+
+ + +
+