From 42c9e1561988c4cff0f7faa1cfa5d238055019d9 Mon Sep 17 00:00:00 2001 From: Aine Date: Fri, 26 Aug 2022 16:00:37 +0300 Subject: [PATCH] add 'nothreads' option, fixes #4 --- bot/bot.go | 2 +- bot/command.go | 8 ++++++++ bot/data.go | 1 + bot/settings.go | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bot/bot.go b/bot/bot.go index 61dbed4..be804b9 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -112,7 +112,7 @@ func (b *Bot) Send(ctx context.Context, email *utils.Email) error { contentParsed := format.RenderMarkdown(text.String(), true, true) var threadID id.EventID - if email.InReplyTo != "" { + if email.InReplyTo != "" && !settings.NoThreads() { threadID = b.getThreadID(roomID, email.InReplyTo) if threadID != "" { contentParsed.SetRelatesTo(&event.RelatesTo{ diff --git a/bot/command.go b/bot/command.go index 2b11cea..c8f985d 100644 --- a/bot/command.go +++ b/bot/command.go @@ -71,6 +71,13 @@ var ( optionNoHTML, ), }, + { + key: optionNoThreads, + description: fmt.Sprintf( + "Get or set `%s` of the room (`true` - ignore email threads; `false` - convert email threads into matrix threads)", + optionNoThreads, + ), + }, } // sanitizers is map of option name => sanitizer function @@ -79,6 +86,7 @@ var ( optionNoSender: utils.SanitizeBoolString, optionNoSubject: utils.SanitizeBoolString, optionNoHTML: utils.SanitizeBoolString, + optionNoThreads: utils.SanitizeBoolString, } ) diff --git a/bot/data.go b/bot/data.go index 74f1b8a..ac35f95 100644 --- a/bot/data.go +++ b/bot/data.go @@ -25,6 +25,7 @@ const ( optionNoSender = "nosender" optionNoSubject = "nosubject" optionNoHTML = "nohtml" + optionNoThreads = "nothreads" ) var migrations = []string{} diff --git a/bot/settings.go b/bot/settings.go index fe3055f..bf5839e 100644 --- a/bot/settings.go +++ b/bot/settings.go @@ -64,6 +64,10 @@ func (s settings) NoHTML() bool { return utils.Bool(s.Get(optionNoHTML)) } +func (s settings) NoThreads() bool { + return utils.Bool(s.Get(optionNoThreads)) +} + // Set option func (s settings) Set(key, value string) { s[strings.ToLower(strings.TrimSpace(key))] = value