2023-03-29 00:09:06 +02:00
|
|
|
package notification
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
statik_fs "github.com/rakyll/statik/fs"
|
|
|
|
"github.com/zitadel/logging"
|
|
|
|
|
|
|
|
"github.com/zitadel/zitadel/internal/command"
|
|
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
"github.com/zitadel/zitadel/internal/notification/handlers"
|
|
|
|
_ "github.com/zitadel/zitadel/internal/notification/statik"
|
|
|
|
"github.com/zitadel/zitadel/internal/query"
|
|
|
|
"github.com/zitadel/zitadel/internal/query/projection"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Start(
|
|
|
|
ctx context.Context,
|
2023-08-24 11:41:52 +02:00
|
|
|
userHandlerCustomConfig, quotaHandlerCustomConfig, telemetryHandlerCustomConfig projection.CustomConfig,
|
2023-07-06 08:38:13 +02:00
|
|
|
telemetryCfg handlers.TelemetryPusherConfig,
|
2023-07-06 19:31:08 +02:00
|
|
|
externalDomain string,
|
2023-03-29 00:09:06 +02:00
|
|
|
externalPort uint16,
|
|
|
|
externalSecure bool,
|
|
|
|
commands *command.Commands,
|
|
|
|
queries *query.Queries,
|
|
|
|
es *eventstore.Eventstore,
|
2023-08-24 11:41:52 +02:00
|
|
|
otpEmailTmpl string,
|
2023-03-29 00:09:06 +02:00
|
|
|
fileSystemPath string,
|
2023-08-24 11:41:52 +02:00
|
|
|
userEncryption, smtpEncryption, smsEncryption crypto.EncryptionAlgorithm,
|
2023-03-29 00:09:06 +02:00
|
|
|
) {
|
|
|
|
statikFS, err := statik_fs.NewWithNamespace("notification")
|
|
|
|
logging.OnError(err).Panic("unable to start listener")
|
2023-07-06 19:31:08 +02:00
|
|
|
q := handlers.NewNotificationQueries(queries, es, externalDomain, externalPort, externalSecure, fileSystemPath, userEncryption, smtpEncryption, smsEncryption, statikFS)
|
2023-10-10 15:20:53 +02:00
|
|
|
c := newChannels(q)
|
2023-10-19 12:19:10 +02:00
|
|
|
handlers.NewUserNotifier(ctx, projection.ApplyCustomConfig(userHandlerCustomConfig), commands, q, c, otpEmailTmpl).Start(ctx)
|
|
|
|
handlers.NewQuotaNotifier(ctx, projection.ApplyCustomConfig(quotaHandlerCustomConfig), commands, q, c).Start(ctx)
|
2023-07-06 08:38:13 +02:00
|
|
|
if telemetryCfg.Enabled {
|
2023-10-19 12:19:10 +02:00
|
|
|
handlers.NewTelemetryPusher(ctx, telemetryCfg, projection.ApplyCustomConfig(telemetryHandlerCustomConfig), commands, q, c).Start(ctx)
|
2023-07-06 08:38:13 +02:00
|
|
|
}
|
2023-03-29 00:09:06 +02:00
|
|
|
}
|