add noinlines option

This commit is contained in:
Aine
2023-03-01 22:50:02 +02:00
parent 01b15b7ac4
commit 2879b10625
5 changed files with 67 additions and 39 deletions

View File

@@ -167,6 +167,15 @@ func (b *Bot) initCommands() commandList {
sanitizer: utils.SanitizeBoolString,
allowed: b.allowOwner,
},
{
key: config.RoomNoInlines,
description: fmt.Sprintf(
"Get or set `%s` of the room (`true` - ignore inline attachments; `false` - upload inline attachments)",
config.RoomNoFiles,
),
sanitizer: utils.SanitizeBoolString,
allowed: b.allowOwner,
},
{allowed: b.allowOwner, description: "mailbox antispam"}, // delimiter
{
key: config.RoomSpamcheckMX,
@@ -491,7 +500,7 @@ func (b *Bot) runSend(ctx context.Context) {
ID := email.MessageID(evt.ID, domain)
for _, to := range tos {
recipients := []string{to}
eml := email.New(ID, "", " "+ID, subject, from, to, to, "", body, htmlBody, nil)
eml := email.New(ID, "", " "+ID, subject, from, to, to, "", body, htmlBody, nil, nil)
data := eml.Compose(b.cfg.GetBot().DKIMPrivateKey())
if data == "" {
b.SendError(ctx, evt.RoomID, "email body is empty")

View File

@@ -26,6 +26,7 @@ const (
RoomNoHTML = "nohtml"
RoomNoThreads = "nothreads"
RoomNoFiles = "nofiles"
RoomNoInlines = "noinlines"
RoomPassword = "password"
RoomSpamcheckDKIM = "spamcheck:dkim"
RoomSpamcheckSMTP = "spamcheck:smtp"
@@ -96,6 +97,10 @@ func (s Room) NoFiles() bool {
return utils.Bool(s.Get(RoomNoFiles))
}
func (s Room) NoInlines() bool {
return utils.Bool(s.Get(RoomNoInlines))
}
func (s Room) SpamcheckDKIM() bool {
return utils.Bool(s.Get(RoomSpamcheckDKIM))
}

View File

@@ -129,6 +129,10 @@ func (b *Bot) IncomingEmail(ctx context.Context, email *email.Email) error {
b.setThreadID(roomID, email.MessageID, threadID)
b.setLastEventID(roomID, threadID, eventID)
if !cfg.NoInlines() {
b.sendFiles(ctx, roomID, email.InlineFiles, cfg.NoThreads(), threadID)
}
if !cfg.NoFiles() {
b.sendFiles(ctx, roomID, email.Files, cfg.NoThreads(), threadID)
}
@@ -179,7 +183,7 @@ func (b *Bot) SendEmailReply(ctx context.Context) {
meta.MessageID = email.MessageID(evt.ID, meta.FromDomain)
meta.References = meta.References + " " + meta.MessageID
b.log.Info("sending email reply: %+v", meta)
eml := email.New(meta.MessageID, meta.InReplyTo, meta.References, meta.Subject, meta.From, meta.To, meta.RcptTo, meta.CC, body, htmlBody, nil)
eml := email.New(meta.MessageID, meta.InReplyTo, meta.References, meta.Subject, meta.From, meta.To, meta.RcptTo, meta.CC, body, htmlBody, nil, nil)
data := eml.Compose(b.cfg.GetBot().DKIMPrivateKey())
if data == "" {
b.SendError(ctx, evt.RoomID, "email body is empty")