fix(smtp): enable default instance config (#7925)

* fix(smtp): enable default instance config

* fix(smtp): enable default instance config

* improve method signature
This commit is contained in:
Elio Bischof 2024-05-07 18:24:53 +02:00 committed by GitHub
parent 1139dfb391
commit f3abbad133
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 13 deletions

View File

@ -389,7 +389,7 @@ func setupSMTPSettings(commands *Commands, validations *[]preparation.Validation
return return
} }
*validations = append(*validations, *validations = append(*validations,
commands.prepareAddSMTPConfig( commands.prepareAddAndActivateSMTPConfig(
instanceAgg, instanceAgg,
smtpConfig.Description, smtpConfig.Description,
smtpConfig.From, smtpConfig.From,

View File

@ -306,7 +306,7 @@ func (c *Commands) getSMTPConfig(ctx context.Context, instanceID, id, domain str
} }
// TODO: SetUpInstance still uses this and would be removed as soon as deprecated PrepareCommands is removed // TODO: SetUpInstance still uses this and would be removed as soon as deprecated PrepareCommands is removed
func (c *Commands) prepareAddSMTPConfig(a *instance.Aggregate, description, from, name, replyTo, hostAndPort, user string, password []byte, tls bool) preparation.Validation { func (c *Commands) prepareAddAndActivateSMTPConfig(a *instance.Aggregate, description, from, name, replyTo, hostAndPort, user string, password []byte, tls bool) preparation.Validation {
return func() (preparation.CreateCommands, error) { return func() (preparation.CreateCommands, error) {
if from = strings.TrimSpace(from); from == "" { if from = strings.TrimSpace(from); from == "" {
return nil, zerrors.ThrowInvalidArgument(nil, "INST-mruNY", "Errors.Invalid.Argument") return nil, zerrors.ThrowInvalidArgument(nil, "INST-mruNY", "Errors.Invalid.Argument")
@ -358,6 +358,11 @@ func (c *Commands) prepareAddSMTPConfig(a *instance.Aggregate, description, from
user, user,
smtpPassword, smtpPassword,
), ),
instance.NewSMTPConfigActivatedEvent(
ctx,
&a.Aggregate,
id,
),
}, nil }, nil
}, nil }, nil
} }

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"github.com/zitadel/zitadel/internal/crypto" "github.com/zitadel/zitadel/internal/crypto"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/zerrors" "github.com/zitadel/zitadel/internal/zerrors"
) )
@ -22,16 +21,15 @@ const (
type SMTPConfigAddedEvent struct { type SMTPConfigAddedEvent struct {
eventstore.BaseEvent `json:"-"` eventstore.BaseEvent `json:"-"`
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
Description string `json:"description,omitempty"` Description string `json:"description,omitempty"`
SenderAddress string `json:"senderAddress,omitempty"` SenderAddress string `json:"senderAddress,omitempty"`
SenderName string `json:"senderName,omitempty"` SenderName string `json:"senderName,omitempty"`
ReplyToAddress string `json:"replyToAddress,omitempty"` ReplyToAddress string `json:"replyToAddress,omitempty"`
TLS bool `json:"tls,omitempty"` TLS bool `json:"tls,omitempty"`
Host string `json:"host,omitempty"` Host string `json:"host,omitempty"`
User string `json:"user,omitempty"` User string `json:"user,omitempty"`
Password *crypto.CryptoValue `json:"password,omitempty"` Password *crypto.CryptoValue `json:"password,omitempty"`
State domain.SMTPConfigState `json:"state,omitempty"`
} }
func NewSMTPConfigAddedEvent( func NewSMTPConfigAddedEvent(