feedback, typos, renaming

This commit is contained in:
Aine
2022-10-10 09:41:22 +03:00
parent d575552237
commit 6f4da59387
8 changed files with 57 additions and 55 deletions

View File

@@ -73,7 +73,9 @@ func (b *Bot) Error(ctx context.Context, roomID id.RoomID, message string, args
b.log.Error(message, args...)
err := fmt.Errorf(message, args...)
sentry.GetHubFromContext(ctx).CaptureException(err)
if hub := sentry.GetHubFromContext(ctx); hub != nil {
sentry.GetHubFromContext(ctx).CaptureException(err)
}
if roomID != "" {
b.SendError(ctx, roomID, err.Error())
}

View File

@@ -145,40 +145,40 @@ func (b *Bot) initCommands() commandList {
},
{allowed: b.allowOwner}, // delimiter
{
key: roomOptionSecurityMX,
key: roomOptionSpamcheckMX,
description: "only accept email from servers which seem prepared to receive it (those having valid MX records) (`true` - enable, `false` - disable)",
sanitizer: utils.SanitizeBoolString,
allowed: b.allowOwner,
},
{
key: roomOptionSecuritySMTP,
key: roomOptionSpamcheckSMTP,
description: "only accept email from servers which seem prepared to receive it (those listening on an SMTP port) (`true` - enable, `false` - disable)",
sanitizer: utils.SanitizeBoolString,
allowed: b.allowOwner,
},
{
key: roomOptionSpamEmails,
key: roomOptionSpamlistEmails,
description: fmt.Sprintf(
"Get or set `%s` of the room (comma-separated list), eg: `spammer@example.com,sspam@example.org`",
roomOptionSpamEmails,
roomOptionSpamlistEmails,
),
sanitizer: utils.SanitizeStringSlice,
allowed: b.allowOwner,
},
{
key: roomOptionSpamHosts,
key: roomOptionSpamlistHosts,
description: fmt.Sprintf(
"Get or set `%s` of the room (comma-separated list), eg: `gmail.com,hotmail.com,outlook.com`",
roomOptionSpamHosts,
"Get or set `%s` of the room (comma-separated list), eg: `spammer.com,scammer.com,morespam.com`",
roomOptionSpamlistHosts,
),
sanitizer: utils.SanitizeStringSlice,
allowed: b.allowOwner,
},
{
key: roomOptionSpamLocalparts,
key: roomOptionSpamlistLocalparts,
description: fmt.Sprintf(
"Get or set `%s` of the room (comma-separated list), eg: `notspam,noreply,no-rely`",
roomOptionSpamLocalparts,
"Get or set `%s` of the room (comma-separated list), eg: `notspam,noreply,no-reply`",
roomOptionSpamlistLocalparts,
),
sanitizer: utils.SanitizeStringSlice,
allowed: b.allowOwner,

View File

@@ -59,8 +59,8 @@ func (b *Bot) GetMapping(mailbox string) (id.RoomID, bool) {
return roomID, ok
}
// GetOptions returns room settings
func (b *Bot) GetOptions(roomID id.RoomID) utils.ValidationOptions {
// GetIFOptions returns incoming email filtering options (room settings)
func (b *Bot) GetIFOptions(roomID id.RoomID) utils.IncomingFilteringOptions {
cfg, err := b.getRoomSettings(roomID)
if err != nil {
b.log.Error("cannot retrieve room settings: %v", err)

View File

@@ -13,21 +13,21 @@ const acRoomSettingsKey = "cc.etke.postmoogle.settings"
// option keys
const (
roomOptionOwner = "owner"
roomOptionMailbox = "mailbox"
roomOptionNoSend = "nosend"
roomOptionNoSender = "nosender"
roomOptionNoRecipient = "norecipient"
roomOptionNoSubject = "nosubject"
roomOptionNoHTML = "nohtml"
roomOptionNoThreads = "nothreads"
roomOptionNoFiles = "nofiles"
roomOptionPassword = "password"
roomOptionSecuritySMTP = "spamcheck:smtp"
roomOptionSecurityMX = "spamcheck:mx"
roomOptionSpamEmails = "spamlist:emails"
roomOptionSpamHosts = "spamlist:hosts"
roomOptionSpamLocalparts = "spamlist:localparts"
roomOptionOwner = "owner"
roomOptionMailbox = "mailbox"
roomOptionNoSend = "nosend"
roomOptionNoSender = "nosender"
roomOptionNoRecipient = "norecipient"
roomOptionNoSubject = "nosubject"
roomOptionNoHTML = "nohtml"
roomOptionNoThreads = "nothreads"
roomOptionNoFiles = "nofiles"
roomOptionPassword = "password"
roomOptionSpamcheckSMTP = "spamcheck:smtp"
roomOptionSpamcheckMX = "spamcheck:mx"
roomOptionSpamlistEmails = "spamlist:emails"
roomOptionSpamlistHosts = "spamlist:hosts"
roomOptionSpamlistLocalparts = "spamlist:mailboxes"
)
type roomSettings map[string]string
@@ -82,24 +82,24 @@ func (s roomSettings) NoFiles() bool {
return utils.Bool(s.Get(roomOptionNoFiles))
}
func (s roomSettings) SecuritySMTP() bool {
return utils.Bool(s.Get(roomOptionSecuritySMTP))
func (s roomSettings) SpamcheckSMTP() bool {
return utils.Bool(s.Get(roomOptionSpamcheckSMTP))
}
func (s roomSettings) SecurityMX() bool {
return utils.Bool(s.Get(roomOptionSecurityMX))
func (s roomSettings) SpamcheckMX() bool {
return utils.Bool(s.Get(roomOptionSpamcheckMX))
}
func (s roomSettings) SpamEmails() []string {
return utils.StringSlice(s.Get(roomOptionSpamEmails))
func (s roomSettings) SpamlistEmails() []string {
return utils.StringSlice(s.Get(roomOptionSpamlistEmails))
}
func (s roomSettings) SpamHosts() []string {
return utils.StringSlice(s.Get(roomOptionSpamHosts))
func (s roomSettings) SpamlistHosts() []string {
return utils.StringSlice(s.Get(roomOptionSpamlistHosts))
}
func (s roomSettings) SpamLocalparts() []string {
return utils.StringSlice(s.Get(roomOptionSpamLocalparts))
func (s roomSettings) SpamlistLocalparts() []string {
return utils.StringSlice(s.Get(roomOptionSpamlistLocalparts))
}
// ContentOptions converts room display settings to content options