fixed the notification service error when the user's display name contained special characters

This commit is contained in:
Roman Perekhod
2024-06-28 13:24:37 +02:00
parent eb5a9ceade
commit f29b254333
8 changed files with 113 additions and 16 deletions
@@ -3,6 +3,8 @@ package parser
import (
"errors"
"fmt"
"net/mail"
"strings"
ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config"
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
@@ -54,6 +56,17 @@ func Validate(cfg *config.Config) error {
}
}
{
if strings.TrimSpace(cfg.Notifications.SMTP.Sender) == "" {
return fmt.Errorf("the 'smtp_sender' must be a valid single RFC 5322 address. parsing error: the address cannot be empty")
}
if s, err := mail.ParseAddress(cfg.Notifications.SMTP.Sender); err == nil {
cfg.Notifications.SMTP.Sender = s.String()
} else {
return fmt.Errorf("the 'smtp_sender' must be a valid single RFC 5322 address. parsing error %w", err)
}
}
if cfg.ServiceAccount.ServiceAccountID == "" {
return shared.MissingServiceAccountID(cfg.Service.Name)
}