zitadel/internal/repository/iam/event_default_language.go
Fabi e3528ff0b2
feat: Config to eventstore (#3158)
* feat: add default language to eventstore

* feat: add secret generator configs events

* feat: tests

* feat: secret generators in eventstore

* feat: secret generators in eventstore

* feat: smtp config in eventstore

* feat: smtp config in eventstore

* feat: smtp config in eventstore

* feat: smtp config in eventstore

* feat: smtp config in eventstore

* fix: migrations

* fix migration version

* fix test

* feat: change secret generator type to enum

* feat: change smtp attribute names

* feat: change smtp attribute names

* feat: remove engryption algorithms from command side

* feat: remove engryption algorithms from command side

* feat: smtp config

* feat: smtp config

* format smtp from header

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-02-16 15:49:17 +00:00

58 lines
1.2 KiB
Go

package iam
import (
"context"
"encoding/json"
"github.com/caos/zitadel/internal/eventstore"
"golang.org/x/text/language"
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/repository"
)
const (
DefaultLanguageSetEventType eventstore.EventType = "iam.default.language.set"
)
type DefaultLanguageSetEvent struct {
eventstore.BaseEvent `json:"-"`
Language language.Tag `json:"language"`
}
func (e *DefaultLanguageSetEvent) Data() interface{} {
return e
}
func (e *DefaultLanguageSetEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewDefaultLanguageSetEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
language language.Tag,
) *DefaultLanguageSetEvent {
return &DefaultLanguageSetEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
aggregate,
DefaultLanguageSetEventType,
),
Language: language,
}
}
func DefaultLanguageSetMapper(event *repository.Event) (eventstore.Event, error) {
e := &DefaultLanguageSetEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
}
err := json.Unmarshal(event.Data, e)
if err != nil {
return nil, errors.ThrowInternal(err, "IAM-3j9fs", "unable to unmarshal default language set")
}
return e, nil
}