diff --git a/internal/api/grpc/admin/iam_settings_converter.go b/internal/api/grpc/admin/iam_settings_converter.go index d625d16a5a..c93f8fbf4f 100644 --- a/internal/api/grpc/admin/iam_settings_converter.go +++ b/internal/api/grpc/admin/iam_settings_converter.go @@ -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, diff --git a/internal/api/grpc/admin/sms_converter.go b/internal/api/grpc/admin/sms_converter.go index 92edd11ebb..08ca931a7a 100644 --- a/internal/api/grpc/admin/sms_converter.go +++ b/internal/api/grpc/admin/sms_converter.go @@ -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, } diff --git a/internal/command/instance.go b/internal/command/instance.go index 8e7087c3d7..230607dc93 100644 --- a/internal/command/instance.go +++ b/internal/command/instance.go @@ -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 diff --git a/internal/command/instance_debug_notification_file.go b/internal/command/instance_debug_notification_file.go index 9f690d2660..830b4e1b63 100644 --- a/internal/command/instance_debug_notification_file.go +++ b/internal/command/instance_debug_notification_file.go @@ -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 diff --git a/internal/command/instance_debug_notification_file_test.go b/internal/command/instance_debug_notification_file_test.go index 4a4d608658..375f45b142 100644 --- a/internal/command/instance_debug_notification_file_test.go +++ b/internal/command/instance_debug_notification_file_test.go @@ -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, }, diff --git a/internal/command/instance_debug_notification_log.go b/internal/command/instance_debug_notification_log.go index 3d4efbff96..fd4c42cb18 100644 --- a/internal/command/instance_debug_notification_log.go +++ b/internal/command/instance_debug_notification_log.go @@ -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 diff --git a/internal/command/instance_debug_notification_log_test.go b/internal/command/instance_debug_notification_log_test.go index 051d3b7cd5..ff66ab4d69 100644 --- a/internal/command/instance_debug_notification_log_test.go +++ b/internal/command/instance_debug_notification_log_test.go @@ -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, }, diff --git a/internal/command/sms_config.go b/internal/command/sms_config.go index 71ec8a7d27..0d37d2b12f 100644 --- a/internal/command/sms_config.go +++ b/internal/command/sms_config.go @@ -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") } diff --git a/internal/command/sms_config_test.go b/internal/command/sms_config_test.go index 8c6b40972b..99f738c326 100644 --- a/internal/command/sms_config_test.go +++ b/internal/command/sms_config_test.go @@ -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", diff --git a/internal/command/smtp.go b/internal/command/smtp.go index a86249266f..eb668e491d 100644 --- a/internal/command/smtp.go +++ b/internal/command/smtp.go @@ -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) diff --git a/internal/command/smtp_test.go b/internal/command/smtp_test.go index 8438b9a3f1..859aca211e 100644 --- a/internal/command/smtp_test.go +++ b/internal/command/smtp_test.go @@ -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", diff --git a/internal/notification/channels/fs/channel.go b/internal/notification/channels/fs/channel.go index 72467c0701..61dffda873 100644 --- a/internal/notification/channels/fs/channel.go +++ b/internal/notification/channels/fs/channel.go @@ -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 } diff --git a/internal/notification/channels/fs/config.go b/internal/notification/channels/fs/config.go index 7d3569282b..76ede75371 100644 --- a/internal/notification/channels/fs/config.go +++ b/internal/notification/channels/fs/config.go @@ -1,6 +1,6 @@ package fs -type FSConfig struct { +type Config struct { Enabled bool Compact bool Path string diff --git a/internal/notification/channels/log/channel.go b/internal/notification/channels/log/channel.go index fbe4bb7ace..e0f981d205 100644 --- a/internal/notification/channels/log/channel.go +++ b/internal/notification/channels/log/channel.go @@ -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") diff --git a/internal/notification/channels/log/config.go b/internal/notification/channels/log/config.go index 7e9946bc15..7f78091e76 100644 --- a/internal/notification/channels/log/config.go +++ b/internal/notification/channels/log/config.go @@ -1,6 +1,6 @@ package log -type LogConfig struct { +type Config struct { Enabled bool Compact bool } diff --git a/internal/notification/channels/smtp/channel.go b/internal/notification/channels/smtp/channel.go index f20bd1330d..18a4634ebb 100644 --- a/internal/notification/channels/smtp/channel.go +++ b/internal/notification/channels/smtp/channel.go @@ -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 diff --git a/internal/notification/channels/smtp/config.go b/internal/notification/channels/smtp/config.go index bfa5abda35..8a856d7b61 100644 --- a/internal/notification/channels/smtp/config.go +++ b/internal/notification/channels/smtp/config.go @@ -1,6 +1,6 @@ package smtp -type EmailConfig struct { +type Config struct { SMTP SMTP Tls bool From string diff --git a/internal/notification/channels/twilio/channel.go b/internal/notification/channels/twilio/channel.go index ff9b6b126a..8c4a33e7e5 100644 --- a/internal/notification/channels/twilio/channel.go +++ b/internal/notification/channels/twilio/channel.go @@ -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") diff --git a/internal/notification/channels/twilio/config.go b/internal/notification/channels/twilio/config.go index d3f462d1b3..dc9550d766 100644 --- a/internal/notification/channels/twilio/config.go +++ b/internal/notification/channels/twilio/config.go @@ -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 != "" } diff --git a/internal/notification/projection.go b/internal/notification/projection.go index 4815a8ef77..5534dfa09c 100644 --- a/internal/notification/projection.go +++ b/internal/notification/projection.go @@ -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 } diff --git a/internal/notification/senders/debug.go b/internal/notification/senders/debug.go index cc512858c6..e06e214f30 100644 --- a/internal/notification/senders/debug.go +++ b/internal/notification/senders/debug.go @@ -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 ) diff --git a/internal/notification/senders/email.go b/internal/notification/senders/email.go index 3b3aa4a2cd..8f5103506a 100644 --- a/internal/notification/senders/email.go +++ b/internal/notification/senders/email.go @@ -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 { diff --git a/internal/notification/senders/sms.go b/internal/notification/senders/sms.go index d7b5f5ff64..0b2cdbfb74 100644 --- a/internal/notification/senders/sms.go +++ b/internal/notification/senders/sms.go @@ -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)) diff --git a/internal/notification/types/notification.go b/internal/notification/types/notification.go index 117e272add..e990626782 100644 --- a/internal/notification/types/notification.go +++ b/internal/notification/types/notification.go @@ -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 { diff --git a/internal/notification/types/user_email.go b/internal/notification/types/user_email.go index afcc302835..6f211996f1 100644 --- a/internal/notification/types/user_email.go +++ b/internal/notification/types/user_email.go @@ -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}, diff --git a/internal/notification/types/user_phone.go b/internal/notification/types/user_phone.go index ea9462ff97..b66cf48e0e 100644 --- a/internal/notification/types/user_phone.go +++ b/internal/notification/types/user_phone.go @@ -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 { diff --git a/internal/repository/quota/events.go b/internal/repository/quota/events.go index e0f8a5fcda..3f889a01da 100644 --- a/internal/repository/quota/events.go +++ b/internal/repository/quota/events.go @@ -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