Email validations
This commit is contained in:
@@ -145,8 +145,8 @@ func (b *Bot) initCommands() commandList {
|
||||
},
|
||||
{allowed: b.allowOwner}, // delimiter
|
||||
{
|
||||
key: roomOptionSecurityEmail,
|
||||
description: "Enforce sender email address validation (`true` - enforce, `false` - disable)",
|
||||
key: roomOptionSecurityMX,
|
||||
description: "Enforce sender email MX check (`true` - enforce, `false` - disable)",
|
||||
sanitizer: utils.SanitizeBoolString,
|
||||
allowed: b.allowOwner,
|
||||
},
|
||||
|
||||
11
bot/email.go
11
bot/email.go
@@ -59,6 +59,17 @@ 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 {
|
||||
cfg, err := b.getRoomSettings(roomID)
|
||||
if err != nil {
|
||||
b.log.Error("cannot retrieve room settings: %v", err)
|
||||
return roomSettings{}
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
||||
// Send email to matrix room
|
||||
func (b *Bot) Send2Matrix(ctx context.Context, email *utils.Email, incoming bool) error {
|
||||
roomID, ok := b.GetMapping(email.Mailbox(incoming))
|
||||
|
||||
@@ -24,7 +24,7 @@ const (
|
||||
roomOptionNoFiles = "nofiles"
|
||||
roomOptionPassword = "password"
|
||||
roomOptionSecuritySMTP = "security:smtp"
|
||||
roomOptionSecurityEmail = "security:email"
|
||||
roomOptionSecurityMX = "security:mx"
|
||||
roomOptionSpamEmails = "spam:emails"
|
||||
roomOptionSpamHosts = "spam:hosts"
|
||||
roomOptionSpamLocalparts = "spam:localparts"
|
||||
@@ -86,8 +86,8 @@ func (s roomSettings) SecuritySMTP() bool {
|
||||
return utils.Bool(s.Get(roomOptionSecuritySMTP))
|
||||
}
|
||||
|
||||
func (s roomSettings) SecurityEmail() bool {
|
||||
return utils.Bool(s.Get(roomOptionSecurityEmail))
|
||||
func (s roomSettings) SecurityMX() bool {
|
||||
return utils.Bool(s.Get(roomOptionSecurityMX))
|
||||
}
|
||||
|
||||
func (s roomSettings) SpamEmails() []string {
|
||||
|
||||
Reference in New Issue
Block a user