mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
email action: allow to configure Bcc
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -474,6 +474,7 @@ func (c EventActionCommandConfig) GetArgumentsAsString() string {
|
||||
// EventActionEmailConfig defines the configuration options for SMTP event actions
|
||||
type EventActionEmailConfig struct {
|
||||
Recipients []string `json:"recipients,omitempty"`
|
||||
Bcc []string `json:"bcc,omitempty"`
|
||||
Subject string `json:"subject,omitempty"`
|
||||
Body string `json:"body,omitempty"`
|
||||
Attachments []string `json:"attachments,omitempty"`
|
||||
@@ -485,6 +486,11 @@ func (c EventActionEmailConfig) GetRecipientsAsString() string {
|
||||
return strings.Join(c.Recipients, ",")
|
||||
}
|
||||
|
||||
// GetBccAsString returns the list of bcc as comma separated string
|
||||
func (c EventActionEmailConfig) GetBccAsString() string {
|
||||
return strings.Join(c.Bcc, ",")
|
||||
}
|
||||
|
||||
// GetAttachmentsAsString returns the list of attachments as comma separated string
|
||||
func (c EventActionEmailConfig) GetAttachmentsAsString() string {
|
||||
return strings.Join(c.Attachments, ",")
|
||||
@@ -509,6 +515,12 @@ func (c *EventActionEmailConfig) validate() error {
|
||||
return util.NewValidationError("invalid email recipients")
|
||||
}
|
||||
}
|
||||
c.Bcc = util.RemoveDuplicates(c.Bcc, false)
|
||||
for _, r := range c.Bcc {
|
||||
if r == "" {
|
||||
return util.NewValidationError("invalid email bcc")
|
||||
}
|
||||
}
|
||||
if c.Subject == "" {
|
||||
return util.NewValidationError("email subject is required")
|
||||
}
|
||||
@@ -897,6 +909,8 @@ func (o *BaseEventActionOptions) getACopy() BaseEventActionOptions {
|
||||
o.SetEmptySecretsIfNil()
|
||||
emailRecipients := make([]string, len(o.EmailConfig.Recipients))
|
||||
copy(emailRecipients, o.EmailConfig.Recipients)
|
||||
emailBcc := make([]string, len(o.EmailConfig.Bcc))
|
||||
copy(emailBcc, o.EmailConfig.Bcc)
|
||||
emailAttachments := make([]string, len(o.EmailConfig.Attachments))
|
||||
copy(emailAttachments, o.EmailConfig.Attachments)
|
||||
cmdArgs := make([]string, len(o.CmdConfig.Args))
|
||||
@@ -941,6 +955,7 @@ func (o *BaseEventActionOptions) getACopy() BaseEventActionOptions {
|
||||
},
|
||||
EmailConfig: EventActionEmailConfig{
|
||||
Recipients: emailRecipients,
|
||||
Bcc: emailBcc,
|
||||
Subject: o.EmailConfig.Subject,
|
||||
ContentType: o.EmailConfig.ContentType,
|
||||
Body: o.EmailConfig.Body,
|
||||
|
||||
Reference in New Issue
Block a user