mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-11 00:25:12 +00:00
feat: mail tempaltes/texts and step 10 (#1266)
* feat: mail template/text events * feat: mail template/text events * feat: mail template/text on iam and org * feat: setup step 10 * fix: add template event * fix: add unique constraints * Update internal/static/i18n/de.yaml Co-authored-by: Livio Amstutz <[email protected]> * Update internal/static/i18n/de.yaml Co-authored-by: Livio Amstutz <[email protected]> * Update internal/static/i18n/de.yaml Co-authored-by: Livio Amstutz <[email protected]> * Update internal/static/i18n/de.yaml Co-authored-by: Livio Amstutz <[email protected]> * Update internal/v2/command/iam_policy_mail_template.go Co-authored-by: Livio Amstutz <[email protected]> * Update internal/v2/command/org_policy_mail_text.go Co-authored-by: Livio Amstutz <[email protected]> * Update internal/v2/command/iam_policy_mail_template.go Co-authored-by: Livio Amstutz <[email protected]> * Update internal/v2/command/iam_policy_mail_text.go Co-authored-by: Livio Amstutz <[email protected]> * Update internal/v2/command/iam_policy_mail_text.go Co-authored-by: Livio Amstutz <[email protected]> * Update internal/v2/command/org_policy_mail_template.go Co-authored-by: Livio Amstutz <[email protected]> * Update internal/v2/command/org_policy_mail_template.go Co-authored-by: Livio Amstutz <[email protected]> * Update internal/v2/command/org_policy_mail_text.go Co-authored-by: Livio Amstutz <[email protected]> * fix: org iam policy Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
"github.com/caos/zitadel/internal/v2/repository/policy"
|
||||
)
|
||||
|
||||
type MailTextWriteModel struct {
|
||||
eventstore.WriteModel
|
||||
|
||||
MailTextType string
|
||||
Language string
|
||||
Title string
|
||||
PreHeader string
|
||||
Subject string
|
||||
Greeting string
|
||||
Text string
|
||||
ButtonText string
|
||||
|
||||
State domain.PolicyState
|
||||
}
|
||||
|
||||
func (wm *MailTextWriteModel) Reduce() error {
|
||||
for _, event := range wm.Events {
|
||||
switch e := event.(type) {
|
||||
case *policy.MailTextAddedEvent:
|
||||
if wm.MailTextType != e.MailTextType || wm.Language != e.Language {
|
||||
continue
|
||||
}
|
||||
wm.Title = e.Title
|
||||
wm.PreHeader = e.PreHeader
|
||||
wm.Subject = e.Subject
|
||||
wm.Greeting = e.Greeting
|
||||
wm.Text = e.Text
|
||||
wm.ButtonText = e.ButtonText
|
||||
wm.State = domain.PolicyStateActive
|
||||
case *policy.MailTextChangedEvent:
|
||||
if wm.MailTextType != e.MailTextType || wm.Language != e.Language {
|
||||
continue
|
||||
}
|
||||
if e.Title != nil {
|
||||
wm.Title = *e.Title
|
||||
}
|
||||
if e.PreHeader != nil {
|
||||
wm.PreHeader = *e.PreHeader
|
||||
}
|
||||
if e.Subject != nil {
|
||||
wm.Subject = *e.Subject
|
||||
}
|
||||
if e.Greeting != nil {
|
||||
wm.Greeting = *e.Greeting
|
||||
}
|
||||
if e.Text != nil {
|
||||
wm.Text = *e.Text
|
||||
}
|
||||
if e.ButtonText != nil {
|
||||
wm.ButtonText = *e.ButtonText
|
||||
}
|
||||
case *policy.MailTextRemovedEvent:
|
||||
wm.State = domain.PolicyStateRemoved
|
||||
}
|
||||
}
|
||||
return wm.WriteModel.Reduce()
|
||||
}
|
||||
Reference in New Issue
Block a user