EventManager: add content type option for email config

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2023-05-17 19:28:13 +02:00
parent da30389989
commit bbaca578cd
8 changed files with 50 additions and 10 deletions

View File

@@ -477,6 +477,7 @@ type EventActionEmailConfig struct {
Subject string `json:"subject,omitempty"`
Body string `json:"body,omitempty"`
Attachments []string `json:"attachments,omitempty"`
ContentType int `json:"content_type,omitempty"`
}
// GetRecipientsAsString returns the list of recipients as comma separated string
@@ -514,6 +515,9 @@ func (c *EventActionEmailConfig) validate() error {
if c.Body == "" {
return util.NewValidationError("email body is required")
}
if c.ContentType < 0 || c.ContentType > 1 {
return util.NewValidationError("invalid email content type")
}
for idx, val := range c.Attachments {
val = strings.TrimSpace(val)
if val == "" {
@@ -938,6 +942,7 @@ func (o *BaseEventActionOptions) getACopy() BaseEventActionOptions {
EmailConfig: EventActionEmailConfig{
Recipients: emailRecipients,
Subject: o.EmailConfig.Subject,
ContentType: o.EmailConfig.ContentType,
Body: o.EmailConfig.Body,
Attachments: emailAttachments,
},