Add ability to hide sender's email address (hide-sender-address setting)
The configuration setting is called `Hide*` instead of `Show*`, because it's backward compatible with existing configuration settings. This is useful for when you setup an email forwarding inbox and you're always sending to it through the same email address. In that case, you don't need to see the email address in each Matrix message. In the future, another similar `bool` setting (`hide-subject`) will land, which controls whether the email's subject is shown in the final message or not. That setting can make use of most of the same setup (all of `handleBooleanConfigurationKey`).
This commit is contained in:
15
bot/bot.go
15
bot/bot.go
@@ -89,17 +89,24 @@ func (b *Bot) Send(ctx context.Context, from, to, subject, body string, files []
|
||||
return errors.New("room not found")
|
||||
}
|
||||
|
||||
settings, err := b.getSettings(ctx, roomID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var text strings.Builder
|
||||
text.WriteString("From: ")
|
||||
text.WriteString(from)
|
||||
text.WriteString("\n\n")
|
||||
if !settings.HideSenderAddress {
|
||||
text.WriteString("From: ")
|
||||
text.WriteString(from)
|
||||
text.WriteString("\n\n")
|
||||
}
|
||||
text.WriteString("# ")
|
||||
text.WriteString(subject)
|
||||
text.WriteString("\n\n")
|
||||
text.WriteString(format.HTMLToMarkdown(body))
|
||||
|
||||
content := format.RenderMarkdown(text.String(), true, true)
|
||||
_, err := b.lp.Send(roomID, content)
|
||||
_, err = b.lp.Send(roomID, content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user