Implement message signature setting
This commit is contained in:
parent
a5d2af2c4e
commit
a1e8bcc561
|
@ -668,14 +668,23 @@ func handleCompose(ctx *alps.Context, msg *OutgoingMessage, options *composeOpti
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleComposeNew(ctx *alps.Context) error {
|
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
|
// These are common mailto URL query parameters
|
||||||
// TODO: cc, bcc
|
// TODO: cc, bcc
|
||||||
return handleCompose(ctx, &OutgoingMessage{
|
return handleCompose(ctx, &OutgoingMessage{
|
||||||
To: strings.Split(ctx.QueryParam("to"), ","),
|
To: strings.Split(ctx.QueryParam("to"), ","),
|
||||||
Subject: ctx.QueryParam("subject"),
|
Subject: ctx.QueryParam("subject"),
|
||||||
Text: ctx.QueryParam("body"),
|
|
||||||
MessageID: mail.GenerateMessageID(),
|
MessageID: mail.GenerateMessageID(),
|
||||||
InReplyTo: ctx.QueryParam("in-reply-to"),
|
InReplyTo: ctx.QueryParam("in-reply-to"),
|
||||||
|
Text: text,
|
||||||
}, &composeOptions{})
|
}, &composeOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1124,6 +1133,7 @@ const maxMessagesPerPage = 100
|
||||||
|
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
MessagesPerPage int
|
MessagesPerPage int
|
||||||
|
Signature string
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadSettings(s alps.Store) (*Settings, error) {
|
func loadSettings(s alps.Store) (*Settings, error) {
|
||||||
|
@ -1143,6 +1153,9 @@ func (s *Settings) check() error {
|
||||||
if s.MessagesPerPage <= 0 || s.MessagesPerPage > maxMessagesPerPage {
|
if s.MessagesPerPage <= 0 || s.MessagesPerPage > maxMessagesPerPage {
|
||||||
return fmt.Errorf("messages per page out of bounds: %v", s.MessagesPerPage)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1162,6 +1175,7 @@ func handleSettings(ctx *alps.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return echo.NewHTTPError(http.StatusBadRequest, "invalid messages per page: %v", err)
|
return echo.NewHTTPError(http.StatusBadRequest, "invalid messages per page: %v", err)
|
||||||
}
|
}
|
||||||
|
settings.Signature = ctx.FormValue("signature")
|
||||||
|
|
||||||
if err := settings.check(); err != nil {
|
if err := settings.check(); err != nil {
|
||||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||||
|
|
|
@ -653,7 +653,8 @@ main table tfoot {
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-group label,
|
.action-group label,
|
||||||
.action-group input {
|
.action-group input,
|
||||||
|
.action-group textarea {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,26 @@
|
||||||
|
|
||||||
<div class="page-wrap">
|
<div class="page-wrap">
|
||||||
<aside>
|
<aside>
|
||||||
<a href="/mailbox/INBOX">Back to inbox</a>
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="/mailbox/INBOX">« Back to inbox</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<main class="settings">
|
<main class="settings">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
|
<div class="action-group">
|
||||||
|
<label for="signature">Message signature</label>
|
||||||
|
<textarea
|
||||||
|
type="number"
|
||||||
|
name="signature"
|
||||||
|
id="signature"
|
||||||
|
rows="5"
|
||||||
|
>{{.Settings.Signature}}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="action-group">
|
<div class="action-group">
|
||||||
<label for="messages_per_page">Messages per page</label>
|
<label for="messages_per_page">Messages per page</label>
|
||||||
<input
|
<input
|
||||||
|
|
Loading…
Reference in a new issue