add !pm threadify option, fixes #60
This commit is contained in:
@@ -116,6 +116,15 @@ func (b *Bot) initCommands() commandList {
|
||||
sanitizer: func(s string) string { return s },
|
||||
allowed: b.allowOwner,
|
||||
},
|
||||
{
|
||||
key: config.RoomThreadify,
|
||||
description: fmt.Sprintf(
|
||||
"Get or set `%s` of the room (`true` - send incoming email body in thread; `false` - send incoming email body as part of the message)",
|
||||
config.RoomThreadify,
|
||||
),
|
||||
sanitizer: utils.SanitizeBoolString,
|
||||
allowed: b.allowOwner,
|
||||
},
|
||||
{
|
||||
key: config.RoomNoSend,
|
||||
description: fmt.Sprintf(
|
||||
|
||||
@@ -22,6 +22,7 @@ const (
|
||||
RoomSignature = "signature"
|
||||
RoomAutoreply = "autoreply"
|
||||
|
||||
RoomThreadify = "threadify"
|
||||
RoomNoCC = "nocc"
|
||||
RoomNoFiles = "nofiles"
|
||||
RoomNoHTML = "nohtml"
|
||||
@@ -79,6 +80,10 @@ func (s Room) Autoreply() string {
|
||||
return s.Get(RoomAutoreply)
|
||||
}
|
||||
|
||||
func (s Room) Threadify() bool {
|
||||
return utils.Bool(s.Get(RoomThreadify))
|
||||
}
|
||||
|
||||
func (s Room) NoSend() bool {
|
||||
return utils.Bool(s.Get(RoomNoSend))
|
||||
}
|
||||
@@ -193,6 +198,7 @@ func (s Room) ContentOptions() *email.ContentOptions {
|
||||
Recipient: !s.NoRecipient(),
|
||||
Subject: !s.NoSubject(),
|
||||
Threads: !s.NoThreads(),
|
||||
Threadify: s.Threadify(),
|
||||
|
||||
ToKey: "cc.etke.postmoogle.to",
|
||||
CcKey: "cc.etke.postmoogle.cc",
|
||||
|
||||
@@ -154,6 +154,13 @@ func (b *Bot) IncomingEmail(ctx context.Context, eml *email.Email) error {
|
||||
b.setThreadID(roomID, eml.MessageID, threadID)
|
||||
b.setLastEventID(roomID, threadID, eventID)
|
||||
|
||||
if newThread && cfg.Threadify() {
|
||||
_, berr := b.lp.Send(roomID, eml.ContentBody(threadID, cfg.ContentOptions()))
|
||||
if berr != nil {
|
||||
return berr
|
||||
}
|
||||
}
|
||||
|
||||
if !cfg.NoInlines() {
|
||||
b.sendFiles(ctx, roomID, eml.InlineFiles, cfg.NoThreads(), threadID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user