2021-06-10 11:49:10 +00:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"golang.org/x/text/language"
|
|
|
|
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
InitCodeMessageType = "InitCode"
|
|
|
|
PasswordResetMessageType = "PasswordReset"
|
|
|
|
VerifyEmailMessageType = "VerifyEmail"
|
|
|
|
VerifyPhoneMessageType = "VerifyPhone"
|
|
|
|
DomainClaimedMessageType = "DomainClaimed"
|
|
|
|
MessageTitle = "Title"
|
|
|
|
MessagePreHeader = "PreHeader"
|
|
|
|
MessageSubject = "Subject"
|
|
|
|
MessageGreeting = "Greeting"
|
|
|
|
MessageText = "Text"
|
|
|
|
MessageButtonText = "ButtonText"
|
2021-07-05 13:10:49 +00:00
|
|
|
MessageFooterText = "Footer"
|
2021-06-10 11:49:10 +00:00
|
|
|
)
|
|
|
|
|
2021-07-13 05:13:39 +00:00
|
|
|
type MessageTexts struct {
|
|
|
|
InitCode CustomMessageText
|
|
|
|
PasswordReset CustomMessageText
|
|
|
|
VerifyEmail CustomMessageText
|
|
|
|
VerifyPhone CustomMessageText
|
|
|
|
DomainClaimed CustomMessageText
|
|
|
|
}
|
|
|
|
|
2021-06-10 11:49:10 +00:00
|
|
|
type CustomMessageText struct {
|
|
|
|
models.ObjectRoot
|
|
|
|
|
|
|
|
State PolicyState
|
|
|
|
Default bool
|
|
|
|
MessageTextType string
|
|
|
|
Language language.Tag
|
|
|
|
Title string
|
|
|
|
PreHeader string
|
|
|
|
Subject string
|
|
|
|
Greeting string
|
|
|
|
Text string
|
|
|
|
ButtonText string
|
|
|
|
FooterText string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *CustomMessageText) IsValid() bool {
|
|
|
|
return m.MessageTextType != "" && m.Language != language.Und
|
|
|
|
}
|
2021-07-13 05:13:39 +00:00
|
|
|
|
|
|
|
func (m *MessageTexts) GetMessageTextByType(msgType string) *CustomMessageText {
|
|
|
|
switch msgType {
|
|
|
|
case InitCodeMessageType:
|
|
|
|
return &m.InitCode
|
|
|
|
case PasswordResetMessageType:
|
|
|
|
return &m.PasswordReset
|
|
|
|
case VerifyEmailMessageType:
|
|
|
|
return &m.VerifyEmail
|
|
|
|
case VerifyPhoneMessageType:
|
|
|
|
return &m.VerifyPhone
|
|
|
|
case DomainClaimedMessageType:
|
|
|
|
return &m.DomainClaimed
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|