mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
29 lines
725 B
Go
29 lines
725 B
Go
package senders
|
|
|
|
import "github.com/zitadel/zitadel/internal/notification/channels"
|
|
|
|
var _ channels.NotificationChannel = (*Chain)(nil)
|
|
|
|
type Chain struct {
|
|
channels []channels.NotificationChannel
|
|
}
|
|
|
|
func chainChannels(channel ...channels.NotificationChannel) *Chain {
|
|
return &Chain{channels: channel}
|
|
}
|
|
|
|
// HandleMessage returns a non nil error from a provider immediately if any occurs
|
|
// messages are sent to channels in the same order they were provided to chainChannels()
|
|
func (c *Chain) HandleMessage(message channels.Message) error {
|
|
for i := range c.channels {
|
|
if err := c.channels[i].HandleMessage(message); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *Chain) Len() int {
|
|
return len(c.channels)
|
|
}
|