add 'norecipient' room option, closes #35
This commit is contained in:
@@ -246,6 +246,7 @@ If you want to change them - check available options in the help message (`!pm h
|
||||
---
|
||||
|
||||
* **!pm nosender** - Get or set `nosender` of the room (`true` - hide email sender; `false` - show email sender)
|
||||
* **!pm norecipient** - Get or set `norecipient` of the room (`true` - hide recipient; `false` - show recipient)
|
||||
* **!pm nosubject** - Get or set `nosubject` of the room (`true` - hide email subject; `false` - show email subject)
|
||||
* **!pm nohtml** - Get or set `nohtml` of the room (`true` - ignore HTML in email; `false` - parse HTML in emails)
|
||||
* **!pm nothreads** - Get or set `nothreads` of the room (`true` - ignore email threads; `false` - convert email threads into matrix threads)
|
||||
|
||||
@@ -98,6 +98,15 @@ func (b *Bot) initCommands() commandList {
|
||||
sanitizer: utils.SanitizeBoolString,
|
||||
allowed: b.allowOwner,
|
||||
},
|
||||
{
|
||||
key: roomOptionNoRecipient,
|
||||
description: fmt.Sprintf(
|
||||
"Get or set `%s` of the room (`true` - hide recipient; `false` - show recipient)",
|
||||
roomOptionNoRecipient,
|
||||
),
|
||||
sanitizer: utils.SanitizeBoolString,
|
||||
allowed: b.allowOwner,
|
||||
},
|
||||
{
|
||||
key: roomOptionNoSubject,
|
||||
description: fmt.Sprintf(
|
||||
|
||||
@@ -13,15 +13,16 @@ const acRoomSettingsKey = "cc.etke.postmoogle.settings"
|
||||
|
||||
// option keys
|
||||
const (
|
||||
roomOptionOwner = "owner"
|
||||
roomOptionMailbox = "mailbox"
|
||||
roomOptionNoSend = "nosend"
|
||||
roomOptionNoSender = "nosender"
|
||||
roomOptionNoSubject = "nosubject"
|
||||
roomOptionNoHTML = "nohtml"
|
||||
roomOptionNoThreads = "nothreads"
|
||||
roomOptionNoFiles = "nofiles"
|
||||
roomOptionPassword = "password"
|
||||
roomOptionOwner = "owner"
|
||||
roomOptionMailbox = "mailbox"
|
||||
roomOptionNoSend = "nosend"
|
||||
roomOptionNoSender = "nosender"
|
||||
roomOptionNoRecipient = "norecipient"
|
||||
roomOptionNoSubject = "nosubject"
|
||||
roomOptionNoHTML = "nohtml"
|
||||
roomOptionNoThreads = "nothreads"
|
||||
roomOptionNoFiles = "nofiles"
|
||||
roomOptionPassword = "password"
|
||||
)
|
||||
|
||||
type roomSettings map[string]string
|
||||
@@ -56,6 +57,10 @@ func (s roomSettings) NoSender() bool {
|
||||
return utils.Bool(s.Get(roomOptionNoSender))
|
||||
}
|
||||
|
||||
func (s roomSettings) NoRecipient() bool {
|
||||
return utils.Bool(s.Get(roomOptionNoRecipient))
|
||||
}
|
||||
|
||||
func (s roomSettings) NoSubject() bool {
|
||||
return utils.Bool(s.Get(roomOptionNoSubject))
|
||||
}
|
||||
@@ -75,10 +80,11 @@ func (s roomSettings) NoFiles() bool {
|
||||
// ContentOptions converts room display settings to content options
|
||||
func (s roomSettings) ContentOptions() *utils.ContentOptions {
|
||||
return &utils.ContentOptions{
|
||||
HTML: !s.NoHTML(),
|
||||
Sender: !s.NoSender(),
|
||||
Subject: !s.NoSubject(),
|
||||
Threads: !s.NoThreads(),
|
||||
HTML: !s.NoHTML(),
|
||||
Sender: !s.NoSender(),
|
||||
Recipient: !s.NoRecipient(),
|
||||
Subject: !s.NoSubject(),
|
||||
Threads: !s.NoThreads(),
|
||||
|
||||
FromKey: eventFromKey,
|
||||
SubjectKey: eventSubjectKey,
|
||||
|
||||
@@ -35,10 +35,11 @@ type Email struct {
|
||||
// ContentOptions represents settings that specify how an email is to be converted to a Matrix message
|
||||
type ContentOptions struct {
|
||||
// On/Off
|
||||
Sender bool
|
||||
Subject bool
|
||||
HTML bool
|
||||
Threads bool
|
||||
Sender bool
|
||||
Recipient bool
|
||||
Subject bool
|
||||
HTML bool
|
||||
Threads bool
|
||||
|
||||
// Keys
|
||||
MessageIDKey string
|
||||
@@ -92,7 +93,12 @@ func (e *Email) Content(threadID id.EventID, options *ContentOptions) *event.Con
|
||||
if options.Sender {
|
||||
text.WriteString("From: ")
|
||||
text.WriteString(e.From)
|
||||
text.WriteString("\n\n")
|
||||
text.WriteString("\n")
|
||||
}
|
||||
if options.Recipient {
|
||||
text.WriteString("To: ")
|
||||
text.WriteString(e.To)
|
||||
text.WriteString("\n")
|
||||
}
|
||||
if options.Subject {
|
||||
text.WriteString("# ")
|
||||
|
||||
Reference in New Issue
Block a user