zitadel/internal/domain/custom_message_text.go
Elio Bischof 343a9428b3
feat: SMS and email OTP texts (#6281)
* manage 2 custom texts proto

* implement methods

* default texts

* console

* improve translations

* lint

* test: fix e2e timeout

* fix translations

* add missing console translations

* remove unused text parts

---------

Co-authored-by: Livio Spring <livio.a@gmail.com>
2023-08-09 05:49:12 +00:00

69 lines
2.1 KiB
Go

package domain
import (
"golang.org/x/text/language"
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
)
const (
InitCodeMessageType = "InitCode"
PasswordResetMessageType = "PasswordReset"
VerifyEmailMessageType = "VerifyEmail"
VerifyPhoneMessageType = "VerifyPhone"
VerifySMSOTPMessageType = "VerifySMSOTP"
VerifyEmailOTPMessageType = "VerifyEmailOTP"
DomainClaimedMessageType = "DomainClaimed"
PasswordlessRegistrationMessageType = "PasswordlessRegistration"
PasswordChangeMessageType = "PasswordChange"
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
PasswordlessRegistration CustomMessageText
PasswordChange 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 IsMessageTextType(textType string) bool {
return textType == InitCodeMessageType ||
textType == PasswordResetMessageType ||
textType == VerifyEmailMessageType ||
textType == VerifyPhoneMessageType ||
textType == VerifySMSOTPMessageType ||
textType == VerifyEmailOTPMessageType ||
textType == DomainClaimedMessageType ||
textType == PasswordlessRegistrationMessageType ||
textType == PasswordChangeMessageType
}