fix(email): set correct logo url (#4426)

This commit is contained in:
Livio Spring 2022-09-21 16:18:55 +02:00 committed by GitHub
parent 38026c9d63
commit 7aef0ccfee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 12 deletions

View File

@ -145,7 +145,7 @@ func startZitadel(config *Config, masterKey string) error {
return fmt.Errorf("cannot start commands: %w", err)
}
notification.Start(ctx, config.Projections.Customizations["notifications"], config.ExternalPort, config.ExternalSecure, commands, queries, eventstoreClient, assets.AssetAPI(config.ExternalSecure), config.SystemDefaults.Notifications.FileSystemPath, keys.User, keys.SMTP, keys.SMS)
notification.Start(ctx, config.Projections.Customizations["notifications"], config.ExternalPort, config.ExternalSecure, commands, queries, eventstoreClient, assets.AssetAPIFromDomain(config.ExternalSecure, config.ExternalPort), config.SystemDefaults.Notifications.FileSystemPath, keys.User, keys.SMTP, keys.SMS)
router := mux.NewRouter()
tlsConfig, err := config.TLS.Config()

View File

@ -55,6 +55,12 @@ func AssetAPI(externalSecure bool) func(context.Context) string {
}
}
func AssetAPIFromDomain(externalSecure bool, externalPort uint16) func(context.Context) string {
return func(ctx context.Context) string {
return http_util.BuildHTTP(authz.GetInstance(ctx).RequestedDomain(), externalPort, externalSecure) + HandlerPrefix
}
}
type Uploader interface {
UploadAsset(ctx context.Context, info string, asset *command.AssetUpload, commands *command.Commands) error
ObjectName(data authz.CtxData) (string, error)

View File

@ -178,7 +178,7 @@ func (p *notificationsProjection) reduceInitCodeAdded(event eventstore.Event) (*
return nil, err
}
origin, err := p.origin(ctx)
ctx, origin, err := p.origin(ctx)
if err != nil {
return nil, err
}
@ -241,7 +241,7 @@ func (p *notificationsProjection) reduceEmailCodeAdded(event eventstore.Event) (
return nil, err
}
origin, err := p.origin(ctx)
ctx, origin, err := p.origin(ctx)
if err != nil {
return nil, err
}
@ -304,7 +304,7 @@ func (p *notificationsProjection) reducePasswordCodeAdded(event eventstore.Event
return nil, err
}
origin, err := p.origin(ctx)
ctx, origin, err := p.origin(ctx)
if err != nil {
return nil, err
}
@ -375,7 +375,7 @@ func (p *notificationsProjection) reduceDomainClaimed(event eventstore.Event) (*
return nil, err
}
origin, err := p.origin(ctx)
ctx, origin, err := p.origin(ctx)
if err != nil {
return nil, err
}
@ -436,7 +436,7 @@ func (p *notificationsProjection) reducePasswordlessCodeRequested(event eventsto
return nil, err
}
origin, err := p.origin(ctx)
ctx, origin, err := p.origin(ctx)
if err != nil {
return nil, err
}
@ -494,7 +494,7 @@ func (p *notificationsProjection) reducePhoneCodeAdded(event eventstore.Event) (
return nil, err
}
origin, err := p.origin(ctx)
ctx, origin, err := p.origin(ctx)
if err != nil {
return nil, err
}
@ -640,21 +640,22 @@ func (p *notificationsProjection) getTranslatorWithOrgTexts(ctx context.Context,
return translator, nil
}
func (p *notificationsProjection) origin(ctx context.Context) (string, error) {
func (p *notificationsProjection) origin(ctx context.Context) (context.Context, string, error) {
primary, err := query.NewInstanceDomainPrimarySearchQuery(true)
if err != nil {
return "", err
return ctx, "", err
}
domains, err := p.queries.SearchInstanceDomains(ctx, &query.InstanceDomainSearchQueries{
Queries: []query.SearchQuery{primary},
})
if err != nil {
return "", err
return ctx, "", err
}
if len(domains.Domains) < 1 {
return "", errors.ThrowInternal(nil, "NOTIF-Ef3r1", "Errors.Notification.NoDomain")
return ctx, "", errors.ThrowInternal(nil, "NOTIF-Ef3r1", "Errors.Notification.NoDomain")
}
return http_utils.BuildHTTP(domains.Domains[0].Domain, p.externalPort, p.externalSecure), nil
ctx = authz.WithRequestedDomain(ctx, domains.Domains[0].Domain)
return ctx, http_utils.BuildHTTP(domains.Domains[0].Domain, p.externalPort, p.externalSecure), nil
}
func setNotificationContext(event eventstore.Aggregate) context.Context {