mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
refactor: rename config structs (#5459)
This commit is contained in:
parent
1896f13952
commit
09abf06d4d
@ -113,8 +113,8 @@ func SecretGeneratorTypeToDomain(generatorType settings_pb.SecretGeneratorType)
|
||||
}
|
||||
}
|
||||
|
||||
func AddSMTPToConfig(req *admin_pb.AddSMTPConfigRequest) *smtp.EmailConfig {
|
||||
return &smtp.EmailConfig{
|
||||
func AddSMTPToConfig(req *admin_pb.AddSMTPConfigRequest) *smtp.Config {
|
||||
return &smtp.Config{
|
||||
Tls: req.Tls,
|
||||
From: req.SenderAddress,
|
||||
FromName: req.SenderName,
|
||||
@ -126,8 +126,8 @@ func AddSMTPToConfig(req *admin_pb.AddSMTPConfigRequest) *smtp.EmailConfig {
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateSMTPToConfig(req *admin_pb.UpdateSMTPConfigRequest) *smtp.EmailConfig {
|
||||
return &smtp.EmailConfig{
|
||||
func UpdateSMTPToConfig(req *admin_pb.UpdateSMTPConfigRequest) *smtp.Config {
|
||||
return &smtp.Config{
|
||||
Tls: req.Tls,
|
||||
From: req.SenderAddress,
|
||||
FromName: req.SenderName,
|
||||
|
@ -64,16 +64,16 @@ func smsStateToPb(state domain.SMSConfigState) settings_pb.SMSProviderConfigStat
|
||||
}
|
||||
}
|
||||
|
||||
func AddSMSConfigTwilioToConfig(req *admin_pb.AddSMSProviderTwilioRequest) *twilio.TwilioConfig {
|
||||
return &twilio.TwilioConfig{
|
||||
func AddSMSConfigTwilioToConfig(req *admin_pb.AddSMSProviderTwilioRequest) *twilio.Config {
|
||||
return &twilio.Config{
|
||||
SID: req.Sid,
|
||||
SenderNumber: req.SenderNumber,
|
||||
Token: req.Token,
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateSMSConfigTwilioToConfig(req *admin_pb.UpdateSMSProviderTwilioRequest) *twilio.TwilioConfig {
|
||||
return &twilio.TwilioConfig{
|
||||
func UpdateSMSConfigTwilioToConfig(req *admin_pb.UpdateSMSProviderTwilioRequest) *twilio.Config {
|
||||
return &twilio.Config{
|
||||
SID: req.Sid,
|
||||
SenderNumber: req.SenderNumber,
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ type InstanceSetup struct {
|
||||
}
|
||||
EmailTemplate []byte
|
||||
MessageTexts []*domain.CustomMessageText
|
||||
SMTPConfiguration *smtp.EmailConfig
|
||||
SMTPConfiguration *smtp.Config
|
||||
OIDCSettings *struct {
|
||||
AccessTokenLifetime time.Duration
|
||||
IdTokenLifetime time.Duration
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/telemetry/tracing"
|
||||
)
|
||||
|
||||
func (c *Commands) AddDebugNotificationProviderFile(ctx context.Context, fileSystemProvider *fs.FSConfig) (*domain.ObjectDetails, error) {
|
||||
func (c *Commands) AddDebugNotificationProviderFile(ctx context.Context, fileSystemProvider *fs.Config) (*domain.ObjectDetails, error) {
|
||||
writeModel := NewInstanceDebugNotificationFileWriteModel(ctx)
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel)
|
||||
events, err := c.addDefaultDebugNotificationFile(ctx, instanceAgg, writeModel, fileSystemProvider)
|
||||
@ -29,7 +29,7 @@ func (c *Commands) AddDebugNotificationProviderFile(ctx context.Context, fileSys
|
||||
return writeModelToObjectDetails(&writeModel.DebugNotificationWriteModel.WriteModel), nil
|
||||
}
|
||||
|
||||
func (c *Commands) addDefaultDebugNotificationFile(ctx context.Context, instanceAgg *eventstore.Aggregate, addedWriteModel *InstanceDebugNotificationFileWriteModel, fileSystemProvider *fs.FSConfig) ([]eventstore.Command, error) {
|
||||
func (c *Commands) addDefaultDebugNotificationFile(ctx context.Context, instanceAgg *eventstore.Aggregate, addedWriteModel *InstanceDebugNotificationFileWriteModel, fileSystemProvider *fs.Config) ([]eventstore.Command, error) {
|
||||
err := c.eventstore.FilterToQueryReducer(ctx, addedWriteModel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -46,7 +46,7 @@ func (c *Commands) addDefaultDebugNotificationFile(ctx context.Context, instance
|
||||
return events, nil
|
||||
}
|
||||
|
||||
func (c *Commands) ChangeDefaultNotificationFile(ctx context.Context, fileSystemProvider *fs.FSConfig) (*domain.ObjectDetails, error) {
|
||||
func (c *Commands) ChangeDefaultNotificationFile(ctx context.Context, fileSystemProvider *fs.Config) (*domain.ObjectDetails, error) {
|
||||
writeModel := NewInstanceDebugNotificationFileWriteModel(ctx)
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel)
|
||||
events, err := c.changeDefaultDebugNotificationProviderFile(ctx, instanceAgg, writeModel, fileSystemProvider)
|
||||
@ -64,7 +64,7 @@ func (c *Commands) ChangeDefaultNotificationFile(ctx context.Context, fileSystem
|
||||
return writeModelToObjectDetails(&writeModel.DebugNotificationWriteModel.WriteModel), nil
|
||||
}
|
||||
|
||||
func (c *Commands) changeDefaultDebugNotificationProviderFile(ctx context.Context, instanceAgg *eventstore.Aggregate, existingProvider *InstanceDebugNotificationFileWriteModel, fileSystemProvider *fs.FSConfig) ([]eventstore.Command, error) {
|
||||
func (c *Commands) changeDefaultDebugNotificationProviderFile(ctx context.Context, instanceAgg *eventstore.Aggregate, existingProvider *InstanceDebugNotificationFileWriteModel, fileSystemProvider *fs.Config) ([]eventstore.Command, error) {
|
||||
err := c.defaultDebugNotificationProviderFileWriteModelByID(ctx, existingProvider)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -22,7 +22,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderFile(t *testing.T) {
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
provider *fs.FSConfig
|
||||
provider *fs.Config
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@ -51,7 +51,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderFile(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: true,
|
||||
Enabled: true,
|
||||
},
|
||||
@ -81,7 +81,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderFile(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: true,
|
||||
},
|
||||
},
|
||||
@ -117,7 +117,7 @@ func TestCommandSide_ChangeDebugNotificationProviderFile(t *testing.T) {
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
provider *fs.FSConfig
|
||||
provider *fs.Config
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@ -139,7 +139,7 @@ func TestCommandSide_ChangeDebugNotificationProviderFile(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: true,
|
||||
Enabled: true,
|
||||
},
|
||||
@ -165,7 +165,7 @@ func TestCommandSide_ChangeDebugNotificationProviderFile(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: true,
|
||||
Enabled: false,
|
||||
},
|
||||
@ -191,7 +191,7 @@ func TestCommandSide_ChangeDebugNotificationProviderFile(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: true,
|
||||
Enabled: true,
|
||||
},
|
||||
@ -227,7 +227,7 @@ func TestCommandSide_ChangeDebugNotificationProviderFile(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: false,
|
||||
Enabled: false,
|
||||
},
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/telemetry/tracing"
|
||||
)
|
||||
|
||||
func (c *Commands) AddDebugNotificationProviderLog(ctx context.Context, fileSystemProvider *fs.FSConfig) (*domain.ObjectDetails, error) {
|
||||
func (c *Commands) AddDebugNotificationProviderLog(ctx context.Context, fileSystemProvider *fs.Config) (*domain.ObjectDetails, error) {
|
||||
writeModel := NewInstanceDebugNotificationLogWriteModel(ctx)
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel)
|
||||
events, err := c.addDefaultDebugNotificationLog(ctx, instanceAgg, writeModel, fileSystemProvider)
|
||||
@ -29,7 +29,7 @@ func (c *Commands) AddDebugNotificationProviderLog(ctx context.Context, fileSyst
|
||||
return writeModelToObjectDetails(&writeModel.DebugNotificationWriteModel.WriteModel), nil
|
||||
}
|
||||
|
||||
func (c *Commands) addDefaultDebugNotificationLog(ctx context.Context, instanceAgg *eventstore.Aggregate, addedWriteModel *InstanceDebugNotificationLogWriteModel, fileSystemProvider *fs.FSConfig) ([]eventstore.Command, error) {
|
||||
func (c *Commands) addDefaultDebugNotificationLog(ctx context.Context, instanceAgg *eventstore.Aggregate, addedWriteModel *InstanceDebugNotificationLogWriteModel, fileSystemProvider *fs.Config) ([]eventstore.Command, error) {
|
||||
err := c.eventstore.FilterToQueryReducer(ctx, addedWriteModel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -46,7 +46,7 @@ func (c *Commands) addDefaultDebugNotificationLog(ctx context.Context, instanceA
|
||||
return events, nil
|
||||
}
|
||||
|
||||
func (c *Commands) ChangeDefaultNotificationLog(ctx context.Context, fileSystemProvider *fs.FSConfig) (*domain.ObjectDetails, error) {
|
||||
func (c *Commands) ChangeDefaultNotificationLog(ctx context.Context, fileSystemProvider *fs.Config) (*domain.ObjectDetails, error) {
|
||||
writeModel := NewInstanceDebugNotificationLogWriteModel(ctx)
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel)
|
||||
event, err := c.changeDefaultDebugNotificationProviderLog(ctx, instanceAgg, writeModel, fileSystemProvider)
|
||||
@ -64,7 +64,7 @@ func (c *Commands) ChangeDefaultNotificationLog(ctx context.Context, fileSystemP
|
||||
return writeModelToObjectDetails(&writeModel.DebugNotificationWriteModel.WriteModel), nil
|
||||
}
|
||||
|
||||
func (c *Commands) changeDefaultDebugNotificationProviderLog(ctx context.Context, instanceAgg *eventstore.Aggregate, existingProvider *InstanceDebugNotificationLogWriteModel, fileSystemProvider *fs.FSConfig) (eventstore.Command, error) {
|
||||
func (c *Commands) changeDefaultDebugNotificationProviderLog(ctx context.Context, instanceAgg *eventstore.Aggregate, existingProvider *InstanceDebugNotificationLogWriteModel, fileSystemProvider *fs.Config) (eventstore.Command, error) {
|
||||
err := c.defaultDebugNotificationProviderLogWriteModelByID(ctx, existingProvider)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -22,7 +22,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
provider *fs.FSConfig
|
||||
provider *fs.Config
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@ -52,7 +52,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: true,
|
||||
Enabled: true,
|
||||
},
|
||||
@ -82,7 +82,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: true,
|
||||
},
|
||||
},
|
||||
@ -113,7 +113,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: true,
|
||||
Enabled: true,
|
||||
},
|
||||
@ -150,7 +150,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
provider *fs.FSConfig
|
||||
provider *fs.Config
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@ -172,7 +172,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: true,
|
||||
Enabled: true,
|
||||
},
|
||||
@ -198,7 +198,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: true,
|
||||
Enabled: false,
|
||||
},
|
||||
@ -234,7 +234,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: false,
|
||||
Enabled: false,
|
||||
},
|
||||
@ -271,7 +271,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
provider: &fs.FSConfig{
|
||||
provider: &fs.Config{
|
||||
Compact: false,
|
||||
Enabled: true,
|
||||
},
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/repository/instance"
|
||||
)
|
||||
|
||||
func (c *Commands) AddSMSConfigTwilio(ctx context.Context, instanceID string, config *twilio.TwilioConfig) (string, *domain.ObjectDetails, error) {
|
||||
func (c *Commands) AddSMSConfigTwilio(ctx context.Context, instanceID string, config *twilio.Config) (string, *domain.ObjectDetails, error) {
|
||||
id, err := c.idGenerator.Next()
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
@ -46,7 +46,7 @@ func (c *Commands) AddSMSConfigTwilio(ctx context.Context, instanceID string, co
|
||||
return id, writeModelToObjectDetails(&smsConfigWriteModel.WriteModel), nil
|
||||
}
|
||||
|
||||
func (c *Commands) ChangeSMSConfigTwilio(ctx context.Context, instanceID, id string, config *twilio.TwilioConfig) (*domain.ObjectDetails, error) {
|
||||
func (c *Commands) ChangeSMSConfigTwilio(ctx context.Context, instanceID, id string, config *twilio.Config) (*domain.ObjectDetails, error) {
|
||||
if id == "" {
|
||||
return nil, caos_errs.ThrowInvalidArgument(nil, "SMS-e9jwf", "Errors.IDMissing")
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ func TestCommandSide_AddSMSConfigTwilio(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
instanceID string
|
||||
sms *twilio.TwilioConfig
|
||||
sms *twilio.Config
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@ -70,7 +70,7 @@ func TestCommandSide_AddSMSConfigTwilio(t *testing.T) {
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
instanceID: "INSTANCE",
|
||||
sms: &twilio.TwilioConfig{
|
||||
sms: &twilio.Config{
|
||||
SID: "sid",
|
||||
Token: "token",
|
||||
SenderNumber: "senderName",
|
||||
@ -112,7 +112,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
ctx context.Context
|
||||
instanceID string
|
||||
id string
|
||||
sms *twilio.TwilioConfig
|
||||
sms *twilio.Config
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@ -133,7 +133,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
sms: &twilio.TwilioConfig{},
|
||||
sms: &twilio.Config{},
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsErrorInvalidArgument,
|
||||
@ -149,7 +149,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
sms: &twilio.TwilioConfig{},
|
||||
sms: &twilio.Config{},
|
||||
instanceID: "INSTANCE",
|
||||
id: "id",
|
||||
},
|
||||
@ -183,7 +183,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
sms: &twilio.TwilioConfig{
|
||||
sms: &twilio.Config{
|
||||
SID: "sid",
|
||||
Token: "token",
|
||||
SenderNumber: "senderName",
|
||||
@ -233,7 +233,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
sms: &twilio.TwilioConfig{
|
||||
sms: &twilio.Config{
|
||||
SID: "sid2",
|
||||
Token: "token2",
|
||||
SenderNumber: "senderName2",
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/repository/instance"
|
||||
)
|
||||
|
||||
func (c *Commands) AddSMTPConfig(ctx context.Context, config *smtp.EmailConfig) (*domain.ObjectDetails, error) {
|
||||
func (c *Commands) AddSMTPConfig(ctx context.Context, config *smtp.Config) (*domain.ObjectDetails, error) {
|
||||
instanceAgg := instance.NewAggregate(authz.GetInstance(ctx).InstanceID())
|
||||
validation := c.prepareAddSMTPConfig(instanceAgg, config.From, config.FromName, config.SMTP.Host, config.SMTP.User, []byte(config.SMTP.Password), config.Tls)
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter, validation)
|
||||
@ -33,7 +33,7 @@ func (c *Commands) AddSMTPConfig(ctx context.Context, config *smtp.EmailConfig)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Commands) ChangeSMTPConfig(ctx context.Context, config *smtp.EmailConfig) (*domain.ObjectDetails, error) {
|
||||
func (c *Commands) ChangeSMTPConfig(ctx context.Context, config *smtp.Config) (*domain.ObjectDetails, error) {
|
||||
instanceAgg := instance.NewAggregate(authz.GetInstance(ctx).InstanceID())
|
||||
validation := c.prepareChangeSMTPConfig(instanceAgg, config.From, config.FromName, config.SMTP.Host, config.SMTP.User, config.Tls)
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter, validation)
|
||||
|
@ -24,7 +24,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
smtp *smtp.EmailConfig
|
||||
smtp *smtp.Config
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@ -55,7 +55,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: true,
|
||||
From: "from@domain.ch",
|
||||
FromName: "name",
|
||||
@ -105,7 +105,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: true,
|
||||
From: "from@domain.ch",
|
||||
FromName: "name",
|
||||
@ -167,7 +167,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: true,
|
||||
From: "from@domain.ch",
|
||||
FromName: "name",
|
||||
@ -191,7 +191,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: true,
|
||||
From: "from@domain.ch",
|
||||
FromName: "name",
|
||||
@ -213,7 +213,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: true,
|
||||
From: "from@domain.ch",
|
||||
FromName: "name",
|
||||
@ -275,7 +275,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: true,
|
||||
From: "from@domain.ch",
|
||||
FromName: "name",
|
||||
@ -319,7 +319,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
smtp *smtp.EmailConfig
|
||||
smtp *smtp.Config
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@ -340,7 +340,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{},
|
||||
smtp: &smtp.Config{},
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsErrorInvalidArgument,
|
||||
@ -356,7 +356,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: true,
|
||||
From: "from@domain.ch",
|
||||
FromName: "name",
|
||||
@ -406,7 +406,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: true,
|
||||
From: "from@wrongdomain.ch",
|
||||
FromName: "name",
|
||||
@ -456,7 +456,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: true,
|
||||
From: "from@domain.ch",
|
||||
FromName: "name",
|
||||
@ -521,7 +521,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: false,
|
||||
From: "from2@domain.ch",
|
||||
FromName: "name2",
|
||||
@ -544,7 +544,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: true,
|
||||
From: "from@domain.ch",
|
||||
FromName: "name",
|
||||
@ -566,7 +566,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: true,
|
||||
From: "from@domain.ch",
|
||||
FromName: "name",
|
||||
@ -632,7 +632,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
smtp: &smtp.EmailConfig{
|
||||
smtp: &smtp.Config{
|
||||
Tls: false,
|
||||
From: "from2@domain.ch",
|
||||
FromName: "name2",
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/notification/messages"
|
||||
)
|
||||
|
||||
func InitFSChannel(config FSConfig) (channels.NotificationChannel, error) {
|
||||
func InitFSChannel(config Config) (channels.NotificationChannel, error) {
|
||||
if err := os.MkdirAll(config.Path, os.ModePerm); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package fs
|
||||
|
||||
type FSConfig struct {
|
||||
type Config struct {
|
||||
Enabled bool
|
||||
Compact bool
|
||||
Path string
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/notification/channels"
|
||||
)
|
||||
|
||||
func InitStdoutChannel(config LogConfig) channels.NotificationChannel {
|
||||
func InitStdoutChannel(config Config) channels.NotificationChannel {
|
||||
|
||||
logging.Log("NOTIF-D0164").Debug("successfully initialized stdout email and sms channel")
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package log
|
||||
|
||||
type LogConfig struct {
|
||||
type Config struct {
|
||||
Enabled bool
|
||||
Compact bool
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ type Email struct {
|
||||
senderName string
|
||||
}
|
||||
|
||||
func InitSMTPChannel(ctx context.Context, getSMTPConfig func(ctx context.Context) (*EmailConfig, error)) (*Email, error) {
|
||||
func InitSMTPChannel(ctx context.Context, getSMTPConfig func(ctx context.Context) (*Config, error)) (*Email, error) {
|
||||
smtpConfig, err := getSMTPConfig(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1,6 +1,6 @@
|
||||
package smtp
|
||||
|
||||
type EmailConfig struct {
|
||||
type Config struct {
|
||||
SMTP SMTP
|
||||
Tls bool
|
||||
From string
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/notification/messages"
|
||||
)
|
||||
|
||||
func InitTwilioChannel(config TwilioConfig) channels.NotificationChannel {
|
||||
func InitTwilioChannel(config Config) channels.NotificationChannel {
|
||||
client := twilio.NewClient(config.SID, config.Token, nil)
|
||||
|
||||
logging.Debug("successfully initialized twilio sms channel")
|
||||
|
@ -1,11 +1,11 @@
|
||||
package twilio
|
||||
|
||||
type TwilioConfig struct {
|
||||
type Config struct {
|
||||
SID string
|
||||
Token string
|
||||
SenderNumber string
|
||||
}
|
||||
|
||||
func (t *TwilioConfig) IsValid() bool {
|
||||
func (t *Config) IsValid() bool {
|
||||
return t.SID != "" && t.Token != "" && t.SenderNumber != ""
|
||||
}
|
||||
|
@ -617,7 +617,7 @@ func (p *notificationsProjection) checkIfAlreadyHandled(ctx context.Context, eve
|
||||
}
|
||||
return len(events) > 0, nil
|
||||
}
|
||||
func (p *notificationsProjection) getSMTPConfig(ctx context.Context) (*smtp.EmailConfig, error) {
|
||||
func (p *notificationsProjection) getSMTPConfig(ctx context.Context) (*smtp.Config, error) {
|
||||
config, err := p.queries.SMTPConfigByAggregateID(ctx, authz.GetInstance(ctx).InstanceID())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -626,7 +626,7 @@ func (p *notificationsProjection) getSMTPConfig(ctx context.Context) (*smtp.Emai
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &smtp.EmailConfig{
|
||||
return &smtp.Config{
|
||||
From: config.SenderAddress,
|
||||
FromName: config.SenderName,
|
||||
Tls: config.TLS,
|
||||
@ -639,7 +639,7 @@ func (p *notificationsProjection) getSMTPConfig(ctx context.Context) (*smtp.Emai
|
||||
}
|
||||
|
||||
// Read iam twilio config
|
||||
func (p *notificationsProjection) getTwilioConfig(ctx context.Context) (*twilio.TwilioConfig, error) {
|
||||
func (p *notificationsProjection) getTwilioConfig(ctx context.Context) (*twilio.Config, error) {
|
||||
active, err := query.NewSMSProviderStateQuery(domain.SMSConfigStateActive)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -655,7 +655,7 @@ func (p *notificationsProjection) getTwilioConfig(ctx context.Context) (*twilio.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &twilio.TwilioConfig{
|
||||
return &twilio.Config{
|
||||
SID: config.TwilioConfig.SID,
|
||||
Token: token,
|
||||
SenderNumber: config.TwilioConfig.SenderNumber,
|
||||
@ -663,24 +663,24 @@ func (p *notificationsProjection) getTwilioConfig(ctx context.Context) (*twilio.
|
||||
}
|
||||
|
||||
// Read iam filesystem provider config
|
||||
func (p *notificationsProjection) getFileSystemProvider(ctx context.Context) (*fs.FSConfig, error) {
|
||||
func (p *notificationsProjection) getFileSystemProvider(ctx context.Context) (*fs.Config, error) {
|
||||
config, err := p.queries.NotificationProviderByIDAndType(ctx, authz.GetInstance(ctx).InstanceID(), domain.NotificationProviderTypeFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &fs.FSConfig{
|
||||
return &fs.Config{
|
||||
Compact: config.Compact,
|
||||
Path: p.fileSystemPath,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Read iam log provider config
|
||||
func (p *notificationsProjection) getLogProvider(ctx context.Context) (*log.LogConfig, error) {
|
||||
func (p *notificationsProjection) getLogProvider(ctx context.Context) (*log.Config, error) {
|
||||
config, err := p.queries.NotificationProviderByIDAndType(ctx, authz.GetInstance(ctx).InstanceID(), domain.NotificationProviderTypeLog)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &log.LogConfig{
|
||||
return &log.Config{
|
||||
Compact: config.Compact,
|
||||
}, nil
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/notification/channels/log"
|
||||
)
|
||||
|
||||
func debugChannels(ctx context.Context, getFileSystemProvider func(ctx context.Context) (*fs.FSConfig, error), getLogProvider func(ctx context.Context) (*log.LogConfig, error)) []channels.NotificationChannel {
|
||||
func debugChannels(ctx context.Context, getFileSystemProvider func(ctx context.Context) (*fs.Config, error), getLogProvider func(ctx context.Context) (*log.Config, error)) []channels.NotificationChannel {
|
||||
var (
|
||||
providers []channels.NotificationChannel
|
||||
)
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/notification/channels/smtp"
|
||||
)
|
||||
|
||||
func EmailChannels(ctx context.Context, emailConfig func(ctx context.Context) (*smtp.EmailConfig, error), getFileSystemProvider func(ctx context.Context) (*fs.FSConfig, error), getLogProvider func(ctx context.Context) (*log.LogConfig, error)) (chain *Chain, err error) {
|
||||
func EmailChannels(ctx context.Context, emailConfig func(ctx context.Context) (*smtp.Config, error), getFileSystemProvider func(ctx context.Context) (*fs.Config, error), getLogProvider func(ctx context.Context) (*log.Config, error)) (chain *Chain, err error) {
|
||||
channels := make([]channels.NotificationChannel, 0, 3)
|
||||
p, err := smtp.InitSMTPChannel(ctx, emailConfig)
|
||||
if err == nil {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/notification/channels/twilio"
|
||||
)
|
||||
|
||||
func SMSChannels(ctx context.Context, twilioConfig *twilio.TwilioConfig, getFileSystemProvider func(ctx context.Context) (*fs.FSConfig, error), getLogProvider func(ctx context.Context) (*log.LogConfig, error)) (chain *Chain, err error) {
|
||||
func SMSChannels(ctx context.Context, twilioConfig *twilio.Config, getFileSystemProvider func(ctx context.Context) (*fs.Config, error), getLogProvider func(ctx context.Context) (*log.Config, error)) (chain *Chain, err error) {
|
||||
channels := make([]channels.NotificationChannel, 0, 3)
|
||||
if twilioConfig != nil {
|
||||
channels = append(channels, twilio.InitTwilioChannel(*twilioConfig))
|
||||
|
@ -24,9 +24,9 @@ func SendEmail(
|
||||
mailhtml string,
|
||||
translator *i18n.Translator,
|
||||
user *query.NotifyUser,
|
||||
emailConfig func(ctx context.Context) (*smtp.EmailConfig, error),
|
||||
getFileSystemProvider func(ctx context.Context) (*fs.FSConfig, error),
|
||||
getLogProvider func(ctx context.Context) (*log.LogConfig, error),
|
||||
emailConfig func(ctx context.Context) (*smtp.Config, error),
|
||||
getFileSystemProvider func(ctx context.Context) (*fs.Config, error),
|
||||
getLogProvider func(ctx context.Context) (*log.Config, error),
|
||||
colors *query.LabelPolicy,
|
||||
assetsPrefix string,
|
||||
) Notify {
|
||||
@ -50,9 +50,9 @@ func SendSMSTwilio(
|
||||
ctx context.Context,
|
||||
translator *i18n.Translator,
|
||||
user *query.NotifyUser,
|
||||
twilioConfig func(ctx context.Context) (*twilio.TwilioConfig, error),
|
||||
getFileSystemProvider func(ctx context.Context) (*fs.FSConfig, error),
|
||||
getLogProvider func(ctx context.Context) (*log.LogConfig, error),
|
||||
twilioConfig func(ctx context.Context) (*twilio.Config, error),
|
||||
getFileSystemProvider func(ctx context.Context) (*fs.Config, error),
|
||||
getLogProvider func(ctx context.Context) (*log.Config, error),
|
||||
colors *query.LabelPolicy,
|
||||
assetsPrefix string,
|
||||
) Notify {
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
)
|
||||
|
||||
func generateEmail(ctx context.Context, user *query.NotifyUser, subject, content string, smtpConfig func(ctx context.Context) (*smtp.EmailConfig, error), getFileSystemProvider func(ctx context.Context) (*fs.FSConfig, error), getLogProvider func(ctx context.Context) (*log.LogConfig, error), lastEmail bool) error {
|
||||
func generateEmail(ctx context.Context, user *query.NotifyUser, subject, content string, smtpConfig func(ctx context.Context) (*smtp.Config, error), getFileSystemProvider func(ctx context.Context) (*fs.Config, error), getLogProvider func(ctx context.Context) (*log.Config, error), lastEmail bool) error {
|
||||
content = html.UnescapeString(content)
|
||||
message := &messages.Email{
|
||||
Recipients: []string{user.VerifiedEmail},
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
)
|
||||
|
||||
func generateSms(ctx context.Context, user *query.NotifyUser, content string, getTwilioProvider func(ctx context.Context) (*twilio.TwilioConfig, error), getFileSystemProvider func(ctx context.Context) (*fs.FSConfig, error), getLogProvider func(ctx context.Context) (*log.LogConfig, error), lastPhone bool) error {
|
||||
func generateSms(ctx context.Context, user *query.NotifyUser, content string, getTwilioProvider func(ctx context.Context) (*twilio.Config, error), getFileSystemProvider func(ctx context.Context) (*fs.Config, error), getLogProvider func(ctx context.Context) (*log.Config, error), lastPhone bool) error {
|
||||
number := ""
|
||||
twilioConfig, err := getTwilioProvider(ctx)
|
||||
if err == nil {
|
||||
|
@ -101,7 +101,7 @@ func AddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "ACTION-4n8vs", "unable to unmarshal quota added")
|
||||
return nil, errors.ThrowInternal(err, "QUOTA-4n8vs", "unable to unmarshal quota added")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
@ -157,7 +157,7 @@ func NotifiedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "ACTION-4n8vs", "unable to unmarshal quota notified")
|
||||
return nil, errors.ThrowInternal(err, "QUOTA-4n8vs", "unable to unmarshal quota notified")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
@ -198,7 +198,7 @@ func RemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "ACTION-4bReE", "unable to unmarshal quota removed")
|
||||
return nil, errors.ThrowInternal(err, "QUOTA-4bReE", "unable to unmarshal quota removed")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
|
Loading…
Reference in New Issue
Block a user