add 'nohtml' option, fixes #5
This commit is contained in:
@@ -103,7 +103,7 @@ func (b *Bot) Send(ctx context.Context, email *utils.Email) error {
|
|||||||
text.WriteString(email.Subject)
|
text.WriteString(email.Subject)
|
||||||
text.WriteString("\n\n")
|
text.WriteString("\n\n")
|
||||||
}
|
}
|
||||||
if email.HTML != "" {
|
if email.HTML != "" && !settings.NoHTML() {
|
||||||
text.WriteString(format.HTMLToMarkdown(email.HTML))
|
text.WriteString(format.HTMLToMarkdown(email.HTML))
|
||||||
} else {
|
} else {
|
||||||
text.WriteString(email.Text)
|
text.WriteString(email.Text)
|
||||||
|
|||||||
@@ -64,6 +64,13 @@ var (
|
|||||||
optionNoSubject,
|
optionNoSubject,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: optionNoHTML,
|
||||||
|
description: fmt.Sprintf(
|
||||||
|
"Get or set `%s` of the room (`true` - ignore HTML in email; `false` - parse HTML in emails)",
|
||||||
|
optionNoHTML,
|
||||||
|
),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// sanitizers is map of option name => sanitizer function
|
// sanitizers is map of option name => sanitizer function
|
||||||
@@ -71,6 +78,7 @@ var (
|
|||||||
optionMailbox: utils.Mailbox,
|
optionMailbox: utils.Mailbox,
|
||||||
optionNoSender: utils.SanitizeBoolString,
|
optionNoSender: utils.SanitizeBoolString,
|
||||||
optionNoSubject: utils.SanitizeBoolString,
|
optionNoSubject: utils.SanitizeBoolString,
|
||||||
|
optionNoHTML: utils.SanitizeBoolString,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const (
|
|||||||
optionMailbox = "mailbox"
|
optionMailbox = "mailbox"
|
||||||
optionNoSender = "nosender"
|
optionNoSender = "nosender"
|
||||||
optionNoSubject = "nosubject"
|
optionNoSubject = "nosubject"
|
||||||
|
optionNoHTML = "nohtml"
|
||||||
)
|
)
|
||||||
|
|
||||||
var migrations = []string{}
|
var migrations = []string{}
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ func (s settings) NoSubject() bool {
|
|||||||
return utils.Bool(s.Get(optionNoSubject))
|
return utils.Bool(s.Get(optionNoSubject))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s settings) NoHTML() bool {
|
||||||
|
return utils.Bool(s.Get(optionNoHTML))
|
||||||
|
}
|
||||||
|
|
||||||
// Set option
|
// Set option
|
||||||
func (s settings) Set(key, value string) {
|
func (s settings) Set(key, value string) {
|
||||||
s[strings.ToLower(strings.TrimSpace(key))] = value
|
s[strings.ToLower(strings.TrimSpace(key))] = value
|
||||||
|
|||||||
Reference in New Issue
Block a user