refactor: rename config structs (#5459)

This commit is contained in:
Elio Bischof 2023-03-16 18:24:30 +01:00 committed by GitHub
parent 1896f13952
commit 09abf06d4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 92 additions and 92 deletions

View File

@ -113,8 +113,8 @@ func SecretGeneratorTypeToDomain(generatorType settings_pb.SecretGeneratorType)
} }
} }
func AddSMTPToConfig(req *admin_pb.AddSMTPConfigRequest) *smtp.EmailConfig { func AddSMTPToConfig(req *admin_pb.AddSMTPConfigRequest) *smtp.Config {
return &smtp.EmailConfig{ return &smtp.Config{
Tls: req.Tls, Tls: req.Tls,
From: req.SenderAddress, From: req.SenderAddress,
FromName: req.SenderName, FromName: req.SenderName,
@ -126,8 +126,8 @@ func AddSMTPToConfig(req *admin_pb.AddSMTPConfigRequest) *smtp.EmailConfig {
} }
} }
func UpdateSMTPToConfig(req *admin_pb.UpdateSMTPConfigRequest) *smtp.EmailConfig { func UpdateSMTPToConfig(req *admin_pb.UpdateSMTPConfigRequest) *smtp.Config {
return &smtp.EmailConfig{ return &smtp.Config{
Tls: req.Tls, Tls: req.Tls,
From: req.SenderAddress, From: req.SenderAddress,
FromName: req.SenderName, FromName: req.SenderName,

View File

@ -64,16 +64,16 @@ func smsStateToPb(state domain.SMSConfigState) settings_pb.SMSProviderConfigStat
} }
} }
func AddSMSConfigTwilioToConfig(req *admin_pb.AddSMSProviderTwilioRequest) *twilio.TwilioConfig { func AddSMSConfigTwilioToConfig(req *admin_pb.AddSMSProviderTwilioRequest) *twilio.Config {
return &twilio.TwilioConfig{ return &twilio.Config{
SID: req.Sid, SID: req.Sid,
SenderNumber: req.SenderNumber, SenderNumber: req.SenderNumber,
Token: req.Token, Token: req.Token,
} }
} }
func UpdateSMSConfigTwilioToConfig(req *admin_pb.UpdateSMSProviderTwilioRequest) *twilio.TwilioConfig { func UpdateSMSConfigTwilioToConfig(req *admin_pb.UpdateSMSProviderTwilioRequest) *twilio.Config {
return &twilio.TwilioConfig{ return &twilio.Config{
SID: req.Sid, SID: req.Sid,
SenderNumber: req.SenderNumber, SenderNumber: req.SenderNumber,
} }

View File

@ -110,7 +110,7 @@ type InstanceSetup struct {
} }
EmailTemplate []byte EmailTemplate []byte
MessageTexts []*domain.CustomMessageText MessageTexts []*domain.CustomMessageText
SMTPConfiguration *smtp.EmailConfig SMTPConfiguration *smtp.Config
OIDCSettings *struct { OIDCSettings *struct {
AccessTokenLifetime time.Duration AccessTokenLifetime time.Duration
IdTokenLifetime time.Duration IdTokenLifetime time.Duration

View File

@ -11,7 +11,7 @@ import (
"github.com/zitadel/zitadel/internal/telemetry/tracing" "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) writeModel := NewInstanceDebugNotificationFileWriteModel(ctx)
instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel) instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel)
events, err := c.addDefaultDebugNotificationFile(ctx, instanceAgg, writeModel, fileSystemProvider) 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 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) err := c.eventstore.FilterToQueryReducer(ctx, addedWriteModel)
if err != nil { if err != nil {
return nil, err return nil, err
@ -46,7 +46,7 @@ func (c *Commands) addDefaultDebugNotificationFile(ctx context.Context, instance
return events, nil 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) writeModel := NewInstanceDebugNotificationFileWriteModel(ctx)
instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel) instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel)
events, err := c.changeDefaultDebugNotificationProviderFile(ctx, instanceAgg, writeModel, fileSystemProvider) 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 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) err := c.defaultDebugNotificationProviderFileWriteModelByID(ctx, existingProvider)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -22,7 +22,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderFile(t *testing.T) {
} }
type args struct { type args struct {
ctx context.Context ctx context.Context
provider *fs.FSConfig provider *fs.Config
} }
type res struct { type res struct {
want *domain.ObjectDetails want *domain.ObjectDetails
@ -51,7 +51,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderFile(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: true, Compact: true,
Enabled: true, Enabled: true,
}, },
@ -81,7 +81,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderFile(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: true, Compact: true,
}, },
}, },
@ -117,7 +117,7 @@ func TestCommandSide_ChangeDebugNotificationProviderFile(t *testing.T) {
} }
type args struct { type args struct {
ctx context.Context ctx context.Context
provider *fs.FSConfig provider *fs.Config
} }
type res struct { type res struct {
want *domain.ObjectDetails want *domain.ObjectDetails
@ -139,7 +139,7 @@ func TestCommandSide_ChangeDebugNotificationProviderFile(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: true, Compact: true,
Enabled: true, Enabled: true,
}, },
@ -165,7 +165,7 @@ func TestCommandSide_ChangeDebugNotificationProviderFile(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: true, Compact: true,
Enabled: false, Enabled: false,
}, },
@ -191,7 +191,7 @@ func TestCommandSide_ChangeDebugNotificationProviderFile(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: true, Compact: true,
Enabled: true, Enabled: true,
}, },
@ -227,7 +227,7 @@ func TestCommandSide_ChangeDebugNotificationProviderFile(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: false, Compact: false,
Enabled: false, Enabled: false,
}, },

View File

@ -11,7 +11,7 @@ import (
"github.com/zitadel/zitadel/internal/telemetry/tracing" "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) writeModel := NewInstanceDebugNotificationLogWriteModel(ctx)
instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel) instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel)
events, err := c.addDefaultDebugNotificationLog(ctx, instanceAgg, writeModel, fileSystemProvider) 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 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) err := c.eventstore.FilterToQueryReducer(ctx, addedWriteModel)
if err != nil { if err != nil {
return nil, err return nil, err
@ -46,7 +46,7 @@ func (c *Commands) addDefaultDebugNotificationLog(ctx context.Context, instanceA
return events, nil 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) writeModel := NewInstanceDebugNotificationLogWriteModel(ctx)
instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel) instanceAgg := InstanceAggregateFromWriteModel(&writeModel.WriteModel)
event, err := c.changeDefaultDebugNotificationProviderLog(ctx, instanceAgg, writeModel, fileSystemProvider) 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 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) err := c.defaultDebugNotificationProviderLogWriteModelByID(ctx, existingProvider)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -22,7 +22,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
} }
type args struct { type args struct {
ctx context.Context ctx context.Context
provider *fs.FSConfig provider *fs.Config
} }
type res struct { type res struct {
want *domain.ObjectDetails want *domain.ObjectDetails
@ -52,7 +52,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: true, Compact: true,
Enabled: true, Enabled: true,
}, },
@ -82,7 +82,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: true, Compact: true,
}, },
}, },
@ -113,7 +113,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: true, Compact: true,
Enabled: true, Enabled: true,
}, },
@ -150,7 +150,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
} }
type args struct { type args struct {
ctx context.Context ctx context.Context
provider *fs.FSConfig provider *fs.Config
} }
type res struct { type res struct {
want *domain.ObjectDetails want *domain.ObjectDetails
@ -172,7 +172,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: true, Compact: true,
Enabled: true, Enabled: true,
}, },
@ -198,7 +198,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: true, Compact: true,
Enabled: false, Enabled: false,
}, },
@ -234,7 +234,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: false, Compact: false,
Enabled: false, Enabled: false,
}, },
@ -271,7 +271,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
provider: &fs.FSConfig{ provider: &fs.Config{
Compact: false, Compact: false,
Enabled: true, Enabled: true,
}, },

View File

@ -10,7 +10,7 @@ import (
"github.com/zitadel/zitadel/internal/repository/instance" "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() id, err := c.idGenerator.Next()
if err != nil { if err != nil {
return "", nil, err return "", nil, err
@ -46,7 +46,7 @@ func (c *Commands) AddSMSConfigTwilio(ctx context.Context, instanceID string, co
return id, writeModelToObjectDetails(&smsConfigWriteModel.WriteModel), nil 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 == "" { if id == "" {
return nil, caos_errs.ThrowInvalidArgument(nil, "SMS-e9jwf", "Errors.IDMissing") return nil, caos_errs.ThrowInvalidArgument(nil, "SMS-e9jwf", "Errors.IDMissing")
} }

View File

@ -27,7 +27,7 @@ func TestCommandSide_AddSMSConfigTwilio(t *testing.T) {
type args struct { type args struct {
ctx context.Context ctx context.Context
instanceID string instanceID string
sms *twilio.TwilioConfig sms *twilio.Config
} }
type res struct { type res struct {
want *domain.ObjectDetails want *domain.ObjectDetails
@ -70,7 +70,7 @@ func TestCommandSide_AddSMSConfigTwilio(t *testing.T) {
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
instanceID: "INSTANCE", instanceID: "INSTANCE",
sms: &twilio.TwilioConfig{ sms: &twilio.Config{
SID: "sid", SID: "sid",
Token: "token", Token: "token",
SenderNumber: "senderName", SenderNumber: "senderName",
@ -112,7 +112,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
ctx context.Context ctx context.Context
instanceID string instanceID string
id string id string
sms *twilio.TwilioConfig sms *twilio.Config
} }
type res struct { type res struct {
want *domain.ObjectDetails want *domain.ObjectDetails
@ -133,7 +133,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
sms: &twilio.TwilioConfig{}, sms: &twilio.Config{},
}, },
res: res{ res: res{
err: caos_errs.IsErrorInvalidArgument, err: caos_errs.IsErrorInvalidArgument,
@ -149,7 +149,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
sms: &twilio.TwilioConfig{}, sms: &twilio.Config{},
instanceID: "INSTANCE", instanceID: "INSTANCE",
id: "id", id: "id",
}, },
@ -183,7 +183,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
sms: &twilio.TwilioConfig{ sms: &twilio.Config{
SID: "sid", SID: "sid",
Token: "token", Token: "token",
SenderNumber: "senderName", SenderNumber: "senderName",
@ -233,7 +233,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
}, },
args: args{ args: args{
ctx: context.Background(), ctx: context.Background(),
sms: &twilio.TwilioConfig{ sms: &twilio.Config{
SID: "sid2", SID: "sid2",
Token: "token2", Token: "token2",
SenderNumber: "senderName2", SenderNumber: "senderName2",

View File

@ -15,7 +15,7 @@ import (
"github.com/zitadel/zitadel/internal/repository/instance" "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()) 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) 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) cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter, validation)
@ -33,7 +33,7 @@ func (c *Commands) AddSMTPConfig(ctx context.Context, config *smtp.EmailConfig)
}, nil }, 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()) instanceAgg := instance.NewAggregate(authz.GetInstance(ctx).InstanceID())
validation := c.prepareChangeSMTPConfig(instanceAgg, config.From, config.FromName, config.SMTP.Host, config.SMTP.User, config.Tls) 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) cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter, validation)

View File

@ -24,7 +24,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
} }
type args struct { type args struct {
ctx context.Context ctx context.Context
smtp *smtp.EmailConfig smtp *smtp.Config
} }
type res struct { type res struct {
want *domain.ObjectDetails want *domain.ObjectDetails
@ -55,7 +55,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: true, Tls: true,
From: "from@domain.ch", From: "from@domain.ch",
FromName: "name", FromName: "name",
@ -105,7 +105,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: true, Tls: true,
From: "from@domain.ch", From: "from@domain.ch",
FromName: "name", FromName: "name",
@ -167,7 +167,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: true, Tls: true,
From: "from@domain.ch", From: "from@domain.ch",
FromName: "name", FromName: "name",
@ -191,7 +191,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: true, Tls: true,
From: "from@domain.ch", From: "from@domain.ch",
FromName: "name", FromName: "name",
@ -213,7 +213,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: true, Tls: true,
From: "from@domain.ch", From: "from@domain.ch",
FromName: "name", FromName: "name",
@ -275,7 +275,7 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: true, Tls: true,
From: "from@domain.ch", From: "from@domain.ch",
FromName: "name", FromName: "name",
@ -319,7 +319,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
} }
type args struct { type args struct {
ctx context.Context ctx context.Context
smtp *smtp.EmailConfig smtp *smtp.Config
} }
type res struct { type res struct {
want *domain.ObjectDetails want *domain.ObjectDetails
@ -340,7 +340,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{}, smtp: &smtp.Config{},
}, },
res: res{ res: res{
err: caos_errs.IsErrorInvalidArgument, err: caos_errs.IsErrorInvalidArgument,
@ -356,7 +356,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: true, Tls: true,
From: "from@domain.ch", From: "from@domain.ch",
FromName: "name", FromName: "name",
@ -406,7 +406,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: true, Tls: true,
From: "from@wrongdomain.ch", From: "from@wrongdomain.ch",
FromName: "name", FromName: "name",
@ -456,7 +456,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: true, Tls: true,
From: "from@domain.ch", From: "from@domain.ch",
FromName: "name", FromName: "name",
@ -521,7 +521,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: false, Tls: false,
From: "from2@domain.ch", From: "from2@domain.ch",
FromName: "name2", FromName: "name2",
@ -544,7 +544,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: true, Tls: true,
From: "from@domain.ch", From: "from@domain.ch",
FromName: "name", FromName: "name",
@ -566,7 +566,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: true, Tls: true,
From: "from@domain.ch", From: "from@domain.ch",
FromName: "name", FromName: "name",
@ -632,7 +632,7 @@ func TestCommandSide_ChangeSMTPConfig(t *testing.T) {
}, },
args: args{ args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"), ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
smtp: &smtp.EmailConfig{ smtp: &smtp.Config{
Tls: false, Tls: false,
From: "from2@domain.ch", From: "from2@domain.ch",
FromName: "name2", FromName: "name2",

View File

@ -19,7 +19,7 @@ import (
"github.com/zitadel/zitadel/internal/notification/messages" "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 { if err := os.MkdirAll(config.Path, os.ModePerm); err != nil {
return nil, err return nil, err
} }

View File

@ -1,6 +1,6 @@
package fs package fs
type FSConfig struct { type Config struct {
Enabled bool Enabled bool
Compact bool Compact bool
Path string Path string

View File

@ -9,7 +9,7 @@ import (
"github.com/zitadel/zitadel/internal/notification/channels" "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") logging.Log("NOTIF-D0164").Debug("successfully initialized stdout email and sms channel")

View File

@ -1,6 +1,6 @@
package log package log
type LogConfig struct { type Config struct {
Enabled bool Enabled bool
Compact bool Compact bool
} }

View File

@ -22,7 +22,7 @@ type Email struct {
senderName string 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) smtpConfig, err := getSMTPConfig(ctx)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -1,6 +1,6 @@
package smtp package smtp
type EmailConfig struct { type Config struct {
SMTP SMTP SMTP SMTP
Tls bool Tls bool
From string From string

View File

@ -9,7 +9,7 @@ import (
"github.com/zitadel/zitadel/internal/notification/messages" "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) client := twilio.NewClient(config.SID, config.Token, nil)
logging.Debug("successfully initialized twilio sms channel") logging.Debug("successfully initialized twilio sms channel")

View File

@ -1,11 +1,11 @@
package twilio package twilio
type TwilioConfig struct { type Config struct {
SID string SID string
Token string Token string
SenderNumber string SenderNumber string
} }
func (t *TwilioConfig) IsValid() bool { func (t *Config) IsValid() bool {
return t.SID != "" && t.Token != "" && t.SenderNumber != "" return t.SID != "" && t.Token != "" && t.SenderNumber != ""
} }

View File

@ -617,7 +617,7 @@ func (p *notificationsProjection) checkIfAlreadyHandled(ctx context.Context, eve
} }
return len(events) > 0, nil 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()) config, err := p.queries.SMTPConfigByAggregateID(ctx, authz.GetInstance(ctx).InstanceID())
if err != nil { if err != nil {
return nil, err return nil, err
@ -626,7 +626,7 @@ func (p *notificationsProjection) getSMTPConfig(ctx context.Context) (*smtp.Emai
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &smtp.EmailConfig{ return &smtp.Config{
From: config.SenderAddress, From: config.SenderAddress,
FromName: config.SenderName, FromName: config.SenderName,
Tls: config.TLS, Tls: config.TLS,
@ -639,7 +639,7 @@ func (p *notificationsProjection) getSMTPConfig(ctx context.Context) (*smtp.Emai
} }
// Read iam twilio config // 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) active, err := query.NewSMSProviderStateQuery(domain.SMSConfigStateActive)
if err != nil { if err != nil {
return nil, err return nil, err
@ -655,7 +655,7 @@ func (p *notificationsProjection) getTwilioConfig(ctx context.Context) (*twilio.
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &twilio.TwilioConfig{ return &twilio.Config{
SID: config.TwilioConfig.SID, SID: config.TwilioConfig.SID,
Token: token, Token: token,
SenderNumber: config.TwilioConfig.SenderNumber, SenderNumber: config.TwilioConfig.SenderNumber,
@ -663,24 +663,24 @@ func (p *notificationsProjection) getTwilioConfig(ctx context.Context) (*twilio.
} }
// Read iam filesystem provider config // 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) config, err := p.queries.NotificationProviderByIDAndType(ctx, authz.GetInstance(ctx).InstanceID(), domain.NotificationProviderTypeFile)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &fs.FSConfig{ return &fs.Config{
Compact: config.Compact, Compact: config.Compact,
Path: p.fileSystemPath, Path: p.fileSystemPath,
}, nil }, nil
} }
// Read iam log provider config // 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) config, err := p.queries.NotificationProviderByIDAndType(ctx, authz.GetInstance(ctx).InstanceID(), domain.NotificationProviderTypeLog)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &log.LogConfig{ return &log.Config{
Compact: config.Compact, Compact: config.Compact,
}, nil }, nil
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/zitadel/zitadel/internal/notification/channels/log" "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 ( var (
providers []channels.NotificationChannel providers []channels.NotificationChannel
) )

View File

@ -9,7 +9,7 @@ import (
"github.com/zitadel/zitadel/internal/notification/channels/smtp" "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) channels := make([]channels.NotificationChannel, 0, 3)
p, err := smtp.InitSMTPChannel(ctx, emailConfig) p, err := smtp.InitSMTPChannel(ctx, emailConfig)
if err == nil { if err == nil {

View File

@ -9,7 +9,7 @@ import (
"github.com/zitadel/zitadel/internal/notification/channels/twilio" "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) channels := make([]channels.NotificationChannel, 0, 3)
if twilioConfig != nil { if twilioConfig != nil {
channels = append(channels, twilio.InitTwilioChannel(*twilioConfig)) channels = append(channels, twilio.InitTwilioChannel(*twilioConfig))

View File

@ -24,9 +24,9 @@ func SendEmail(
mailhtml string, mailhtml string,
translator *i18n.Translator, translator *i18n.Translator,
user *query.NotifyUser, user *query.NotifyUser,
emailConfig func(ctx context.Context) (*smtp.EmailConfig, error), emailConfig func(ctx context.Context) (*smtp.Config, error),
getFileSystemProvider func(ctx context.Context) (*fs.FSConfig, error), getFileSystemProvider func(ctx context.Context) (*fs.Config, error),
getLogProvider func(ctx context.Context) (*log.LogConfig, error), getLogProvider func(ctx context.Context) (*log.Config, error),
colors *query.LabelPolicy, colors *query.LabelPolicy,
assetsPrefix string, assetsPrefix string,
) Notify { ) Notify {
@ -50,9 +50,9 @@ func SendSMSTwilio(
ctx context.Context, ctx context.Context,
translator *i18n.Translator, translator *i18n.Translator,
user *query.NotifyUser, user *query.NotifyUser,
twilioConfig func(ctx context.Context) (*twilio.TwilioConfig, error), twilioConfig func(ctx context.Context) (*twilio.Config, error),
getFileSystemProvider func(ctx context.Context) (*fs.FSConfig, error), getFileSystemProvider func(ctx context.Context) (*fs.Config, error),
getLogProvider func(ctx context.Context) (*log.LogConfig, error), getLogProvider func(ctx context.Context) (*log.Config, error),
colors *query.LabelPolicy, colors *query.LabelPolicy,
assetsPrefix string, assetsPrefix string,
) Notify { ) Notify {

View File

@ -13,7 +13,7 @@ import (
"github.com/zitadel/zitadel/internal/query" "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) content = html.UnescapeString(content)
message := &messages.Email{ message := &messages.Email{
Recipients: []string{user.VerifiedEmail}, Recipients: []string{user.VerifiedEmail},

View File

@ -14,7 +14,7 @@ import (
"github.com/zitadel/zitadel/internal/query" "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 := "" number := ""
twilioConfig, err := getTwilioProvider(ctx) twilioConfig, err := getTwilioProvider(ctx)
if err == nil { if err == nil {

View File

@ -101,7 +101,7 @@ func AddedEventMapper(event *repository.Event) (eventstore.Event, error) {
err := json.Unmarshal(event.Data, e) err := json.Unmarshal(event.Data, e)
if err != nil { 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 return e, nil
@ -157,7 +157,7 @@ func NotifiedEventMapper(event *repository.Event) (eventstore.Event, error) {
err := json.Unmarshal(event.Data, e) err := json.Unmarshal(event.Data, e)
if err != nil { 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 return e, nil
@ -198,7 +198,7 @@ func RemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
err := json.Unmarshal(event.Data, e) err := json.Unmarshal(event.Data, e)
if err != nil { 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 return e, nil