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(
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const (
|
|||||||
roomOptionMailbox = "mailbox"
|
roomOptionMailbox = "mailbox"
|
||||||
roomOptionNoSend = "nosend"
|
roomOptionNoSend = "nosend"
|
||||||
roomOptionNoSender = "nosender"
|
roomOptionNoSender = "nosender"
|
||||||
|
roomOptionNoRecipient = "norecipient"
|
||||||
roomOptionNoSubject = "nosubject"
|
roomOptionNoSubject = "nosubject"
|
||||||
roomOptionNoHTML = "nohtml"
|
roomOptionNoHTML = "nohtml"
|
||||||
roomOptionNoThreads = "nothreads"
|
roomOptionNoThreads = "nothreads"
|
||||||
@@ -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))
|
||||||
}
|
}
|
||||||
@@ -77,6 +82,7 @@ func (s roomSettings) ContentOptions() *utils.ContentOptions {
|
|||||||
return &utils.ContentOptions{
|
return &utils.ContentOptions{
|
||||||
HTML: !s.NoHTML(),
|
HTML: !s.NoHTML(),
|
||||||
Sender: !s.NoSender(),
|
Sender: !s.NoSender(),
|
||||||
|
Recipient: !s.NoRecipient(),
|
||||||
Subject: !s.NoSubject(),
|
Subject: !s.NoSubject(),
|
||||||
Threads: !s.NoThreads(),
|
Threads: !s.NoThreads(),
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ type Email struct {
|
|||||||
type ContentOptions struct {
|
type ContentOptions struct {
|
||||||
// On/Off
|
// On/Off
|
||||||
Sender bool
|
Sender bool
|
||||||
|
Recipient bool
|
||||||
Subject bool
|
Subject bool
|
||||||
HTML bool
|
HTML bool
|
||||||
Threads bool
|
Threads bool
|
||||||
@@ -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