mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-12 09:05:12 +00:00
* implement notification providers * email provider * notification handler * notify users * implement code sent on user eventstore * send email implementation * send init code * handle codes * fix project member handler * add some logs for debug * send emails * text changes * send sms * notification process * send password code * format phone number * test format phone * remove fmts * remove unused code * rename files * add mocks * merge master * Update internal/notification/providers/email/message.go Co-authored-by: Silvan <[email protected]> * Update internal/notification/repository/eventsourcing/handler/notification.go Co-authored-by: Silvan <[email protected]> * Update internal/notification/repository/eventsourcing/handler/notification.go Co-authored-by: Silvan <[email protected]> * Update internal/notification/providers/email/provider.go Co-authored-by: Silvan <[email protected]> * requested changes of mr * move locker to eventstore pkg * Update internal/notification/providers/chat/message.go Co-authored-by: Livio Amstutz <[email protected]> * move locker to eventstore pkg * linebreak * Update internal/notification/providers/email/provider.go Co-authored-by: Silvan <[email protected]> * Update internal/notification/repository/eventsourcing/handler/notification.go Co-authored-by: Silvan <[email protected]> * Update internal/notification/repository/eventsourcing/handler/notification.go Co-authored-by: Silvan <[email protected]> Co-authored-by: Silvan <[email protected]> Co-authored-by: Livio Amstutz <[email protected]>
50 lines
2.0 KiB
Go
50 lines
2.0 KiB
Go
package handler
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/config/types"
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
"github.com/caos/zitadel/internal/eventstore/spooler"
|
|
"github.com/caos/zitadel/internal/management/repository/eventsourcing/view"
|
|
proj_event "github.com/caos/zitadel/internal/project/repository/eventsourcing"
|
|
usr_event "github.com/caos/zitadel/internal/user/repository/eventsourcing"
|
|
"time"
|
|
)
|
|
|
|
type Configs map[string]*Config
|
|
|
|
type Config struct {
|
|
MinimumCycleDuration types.Duration
|
|
}
|
|
|
|
type handler struct {
|
|
view *view.View
|
|
bulkLimit uint64
|
|
cycleDuration time.Duration
|
|
errorCountUntilSkip uint64
|
|
}
|
|
|
|
type EventstoreRepos struct {
|
|
ProjectEvents *proj_event.ProjectEventstore
|
|
UserEvents *usr_event.UserEventstore
|
|
}
|
|
|
|
func Register(configs Configs, bulkLimit, errorCount uint64, view *view.View, eventstore eventstore.Eventstore, repos EventstoreRepos) []spooler.Handler {
|
|
return []spooler.Handler{
|
|
&GrantedProject{handler: handler{view, bulkLimit, configs.cycleDuration("GrantedProject"), errorCount}, eventstore: eventstore, projectEvents: repos.ProjectEvents},
|
|
&ProjectRole{handler: handler{view, bulkLimit, configs.cycleDuration("ProjectRole"), errorCount}, projectEvents: repos.ProjectEvents},
|
|
&ProjectMember{handler: handler{view, bulkLimit, configs.cycleDuration("ProjectMember"), errorCount}, userEvents: repos.UserEvents},
|
|
&ProjectGrantMember{handler: handler{view, bulkLimit, configs.cycleDuration("ProjectGrantMember"), errorCount}, userEvents: repos.UserEvents},
|
|
&Application{handler: handler{view, bulkLimit, configs.cycleDuration("Application"), errorCount}},
|
|
&User{handler: handler{view, bulkLimit, configs.cycleDuration("User"), errorCount}},
|
|
&UserGrant{handler: handler{view, bulkLimit, configs.cycleDuration("UserGrant"), errorCount}, projectEvents: repos.ProjectEvents, userEvents: repos.UserEvents},
|
|
}
|
|
}
|
|
|
|
func (configs Configs) cycleDuration(viewModel string) time.Duration {
|
|
c, ok := configs[viewModel]
|
|
if !ok {
|
|
return 1 * time.Second
|
|
}
|
|
return c.MinimumCycleDuration.Duration
|
|
}
|