mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
03a38fbf1c
* feat: add get custom message text to admin api * feat: read custom message texts from files * feat: get languages in apis * feat: get languages in apis * feat: get languages in apis * feat: pr feedback * feat: docs * feat: merge main
67 lines
1.6 KiB
Go
67 lines
1.6 KiB
Go
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"
|
|
MessageFooterText = "Footer"
|
|
)
|
|
|
|
type MessageTexts struct {
|
|
InitCode CustomMessageText
|
|
PasswordReset CustomMessageText
|
|
VerifyEmail CustomMessageText
|
|
VerifyPhone CustomMessageText
|
|
DomainClaimed CustomMessageText
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
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
|
|
}
|