zitadel/internal/repository/org/custom_text.go
Fabi bdf3887f9e
feat: custom message text (#1801)
* feat: default custom message text

* feat: org custom message text

* feat: org custom message text

* feat: custom messages query side

* feat: default messages

* feat: message text user fields

* feat: check for inactive user

* feat: fix send password reset

* feat: fix custom org text

* feat: add variables to docs

* feat: custom text tests

* feat: fix notifications

* feat: add custom text feature

* feat: add custom text feature

* feat: feature in custom message texts

* feat: add custom text feature in frontend

* feat: merge main

* feat: feature tests

* feat: change phone message in setup

* fix: remove unused code, add event translation

* fix: merge main and fix problems

* fix: english translation file

* fix: migration versions

* fix: setup

* feat: fix pr requests

* feat: fix phone code message

* feat: migration

* feat: setup

* fix: remove unused tests

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-06-10 11:49:10 +00:00

108 lines
2.7 KiB
Go

package org
import (
"context"
"golang.org/x/text/language"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/repository"
"github.com/caos/zitadel/internal/repository/policy"
)
var (
CustomTextSetEventType = orgEventTypePrefix + policy.CustomTextSetEventType
CustomTextRemovedEventType = orgEventTypePrefix + policy.CustomTextRemovedEventType
CustomTextTemplateRemovedEventType = orgEventTypePrefix + policy.CustomTextTemplateRemovedEventType
)
type CustomTextSetEvent struct {
policy.CustomTextSetEvent
}
func NewCustomTextSetEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
template,
key,
text string,
language language.Tag,
) *CustomTextSetEvent {
return &CustomTextSetEvent{
CustomTextSetEvent: *policy.NewCustomTextSetEvent(
eventstore.NewBaseEventForPush(ctx, aggregate, CustomTextSetEventType),
template,
key,
text,
language),
}
}
func CustomTextSetEventMapper(event *repository.Event) (eventstore.EventReader, error) {
e, err := policy.CustomTextSetEventMapper(event)
if err != nil {
return nil, err
}
return &CustomTextSetEvent{CustomTextSetEvent: *e.(*policy.CustomTextSetEvent)}, nil
}
type CustomTextRemovedEvent struct {
policy.CustomTextRemovedEvent
}
func NewCustomTextRemovedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
template,
key string,
language language.Tag,
) *CustomTextRemovedEvent {
return &CustomTextRemovedEvent{
CustomTextRemovedEvent: *policy.NewCustomTextRemovedEvent(
eventstore.NewBaseEventForPush(ctx, aggregate, CustomTextRemovedEventType),
template,
key,
language,
),
}
}
func CustomTextRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
e, err := policy.CustomTextRemovedEventMapper(event)
if err != nil {
return nil, err
}
return &CustomTextRemovedEvent{CustomTextRemovedEvent: *e.(*policy.CustomTextRemovedEvent)}, nil
}
type CustomTextTemplateRemovedEvent struct {
policy.CustomTextTemplateRemovedEvent
}
func NewCustomTextTemplateRemovedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
template string,
language language.Tag,
) *CustomTextTemplateRemovedEvent {
return &CustomTextTemplateRemovedEvent{
CustomTextTemplateRemovedEvent: *policy.NewCustomTextTemplateRemovedEvent(
eventstore.NewBaseEventForPush(ctx, aggregate, CustomTextTemplateRemovedEventType),
template,
language,
),
}
}
func CustomTextTemplateRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
e, err := policy.CustomTextTemplateRemovedEventMapper(event)
if err != nil {
return nil, err
}
return &CustomTextTemplateRemovedEvent{CustomTextTemplateRemovedEvent: *e.(*policy.CustomTextTemplateRemovedEvent)}, nil
}