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 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 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 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)
|
* **!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,
|
sanitizer: utils.SanitizeBoolString,
|
||||||
allowed: b.allowOwner,
|
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,
|
key: roomOptionNoSubject,
|
||||||
description: fmt.Sprintf(
|
description: fmt.Sprintf(
|
||||||
|
|||||||
@@ -13,15 +13,16 @@ const acRoomSettingsKey = "cc.etke.postmoogle.settings"
|
|||||||
|
|
||||||
// option keys
|
// option keys
|
||||||
const (
|
const (
|
||||||
roomOptionOwner = "owner"
|
roomOptionOwner = "owner"
|
||||||
roomOptionMailbox = "mailbox"
|
roomOptionMailbox = "mailbox"
|
||||||
roomOptionNoSend = "nosend"
|
roomOptionNoSend = "nosend"
|
||||||
roomOptionNoSender = "nosender"
|
roomOptionNoSender = "nosender"
|
||||||
roomOptionNoSubject = "nosubject"
|
roomOptionNoRecipient = "norecipient"
|
||||||
roomOptionNoHTML = "nohtml"
|
roomOptionNoSubject = "nosubject"
|
||||||
roomOptionNoThreads = "nothreads"
|
roomOptionNoHTML = "nohtml"
|
||||||
roomOptionNoFiles = "nofiles"
|
roomOptionNoThreads = "nothreads"
|
||||||
roomOptionPassword = "password"
|
roomOptionNoFiles = "nofiles"
|
||||||
|
roomOptionPassword = "password"
|
||||||
)
|
)
|
||||||
|
|
||||||
type roomSettings map[string]string
|
type roomSettings map[string]string
|
||||||
@@ -56,6 +57,10 @@ func (s roomSettings) NoSender() bool {
|
|||||||
return utils.Bool(s.Get(roomOptionNoSender))
|
return utils.Bool(s.Get(roomOptionNoSender))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s roomSettings) NoRecipient() bool {
|
||||||
|
return utils.Bool(s.Get(roomOptionNoRecipient))
|
||||||
|
}
|
||||||
|
|
||||||
func (s roomSettings) NoSubject() bool {
|
func (s roomSettings) NoSubject() bool {
|
||||||
return utils.Bool(s.Get(roomOptionNoSubject))
|
return utils.Bool(s.Get(roomOptionNoSubject))
|
||||||
}
|
}
|
||||||
@@ -75,10 +80,11 @@ func (s roomSettings) NoFiles() bool {
|
|||||||
// ContentOptions converts room display settings to content options
|
// ContentOptions converts room display settings to content options
|
||||||
func (s roomSettings) ContentOptions() *utils.ContentOptions {
|
func (s roomSettings) ContentOptions() *utils.ContentOptions {
|
||||||
return &utils.ContentOptions{
|
return &utils.ContentOptions{
|
||||||
HTML: !s.NoHTML(),
|
HTML: !s.NoHTML(),
|
||||||
Sender: !s.NoSender(),
|
Sender: !s.NoSender(),
|
||||||
Subject: !s.NoSubject(),
|
Recipient: !s.NoRecipient(),
|
||||||
Threads: !s.NoThreads(),
|
Subject: !s.NoSubject(),
|
||||||
|
Threads: !s.NoThreads(),
|
||||||
|
|
||||||
FromKey: eventFromKey,
|
FromKey: eventFromKey,
|
||||||
SubjectKey: eventSubjectKey,
|
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
|
// ContentOptions represents settings that specify how an email is to be converted to a Matrix message
|
||||||
type ContentOptions struct {
|
type ContentOptions struct {
|
||||||
// On/Off
|
// On/Off
|
||||||
Sender bool
|
Sender bool
|
||||||
Subject bool
|
Recipient bool
|
||||||
HTML bool
|
Subject bool
|
||||||
Threads bool
|
HTML bool
|
||||||
|
Threads bool
|
||||||
|
|
||||||
// Keys
|
// Keys
|
||||||
MessageIDKey string
|
MessageIDKey string
|
||||||
@@ -92,7 +93,12 @@ func (e *Email) Content(threadID id.EventID, options *ContentOptions) *event.Con
|
|||||||
if options.Sender {
|
if options.Sender {
|
||||||
text.WriteString("From: ")
|
text.WriteString("From: ")
|
||||||
text.WriteString(e.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 {
|
if options.Subject {
|
||||||
text.WriteString("# ")
|
text.WriteString("# ")
|
||||||
|
|||||||
Reference in New Issue
Block a user