translation

package
v0.0.0-...-09efcc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TemplateMessageVerificationSMSTXT    = template.RegisterMessagePlainText("messages/verification_sms.txt")
	TemplateMessageVerificationEmailTXT  = template.RegisterMessagePlainText("messages/verification_email.txt")
	TemplateMessageVerificationEmailHTML = template.RegisterMessageHTML("messages/verification_email.html")

	TemplateMessageSetupPrimaryOOBSMSTXT    = template.RegisterMessagePlainText("messages/setup_primary_oob_sms.txt")
	TemplateMessageSetupPrimaryOOBEmailTXT  = template.RegisterMessagePlainText("messages/setup_primary_oob_email.txt")
	TemplateMessageSetupPrimaryOOBEmailHTML = template.RegisterMessageHTML("messages/setup_primary_oob_email.html")

	TemplateMessageSetupSecondaryOOBSMSTXT    = template.RegisterMessagePlainText("messages/setup_secondary_oob_sms.txt")
	TemplateMessageSetupSecondaryOOBEmailTXT  = template.RegisterMessagePlainText("messages/setup_secondary_oob_email.txt")
	TemplateMessageSetupSecondaryOOBEmailHTML = template.RegisterMessageHTML("messages/setup_secondary_oob_email.html")

	TemplateMessageAuthenticatePrimaryOOBSMSTXT    = template.RegisterMessagePlainText("messages/authenticate_primary_oob_sms.txt")
	TemplateMessageAuthenticatePrimaryOOBEmailTXT  = template.RegisterMessagePlainText("messages/authenticate_primary_oob_email.txt")
	TemplateMessageAuthenticatePrimaryOOBEmailHTML = template.RegisterMessageHTML("messages/authenticate_primary_oob_email.html")

	TemplateMessageAuthenticatePrimaryLoginLinkEmailTXT  = template.RegisterMessagePlainText("messages/authenticate_primary_login_link.txt")
	TemplateMessageAuthenticatePrimaryLoginLinkEmailHTML = template.RegisterMessageHTML("messages/authenticate_primary_login_link.html")

	TemplateMessageAuthenticateSecondaryOOBSMSTXT    = template.RegisterMessagePlainText("messages/authenticate_secondary_oob_sms.txt")
	TemplateMessageAuthenticateSecondaryOOBEmailTXT  = template.RegisterMessagePlainText("messages/authenticate_secondary_oob_email.txt")
	TemplateMessageAuthenticateSecondaryOOBEmailHTML = template.RegisterMessageHTML("messages/authenticate_secondary_oob_email.html")

	TemplateMessageSetupPrimaryLoginLinkEmailTXT  = template.RegisterMessagePlainText("messages/setup_primary_login_link.txt")
	TemplateMessageSetupPrimaryLoginLinkEmailHTML = template.RegisterMessageHTML("messages/setup_primary_login_link.html")

	TemplateMessageSetupSecondaryLoginLinkEmailTXT  = template.RegisterMessagePlainText("messages/setup_secondary_login_link.txt")
	TemplateMessageSetupSecondaryLoginLinkEmailHTML = template.RegisterMessageHTML("messages/setup_secondary_login_link.html")

	TemplateMessageAuthenticateSecondaryLoginLinkEmailTXT  = template.RegisterMessagePlainText("messages/authenticate_secondary_login_link.txt")
	TemplateMessageAuthenticateSecondaryLoginLinkEmailHTML = template.RegisterMessageHTML("messages/authenticate_secondary_login_link.html")

	TemplateMessageForgotPasswordLinkSMSTXT    = template.RegisterMessagePlainText("messages/forgot_password_sms.txt")
	TemplateMessageForgotPasswordLinkEmailTXT  = template.RegisterMessagePlainText("messages/forgot_password_email.txt")
	TemplateMessageForgotPasswordLinkEmailHTML = template.RegisterMessageHTML("messages/forgot_password_email.html")

	TemplateMessageForgotPasswordOOBSMSTXT    = template.RegisterMessagePlainText("messages/forgot_password_oob_sms.txt")
	TemplateMessageForgotPasswordOOBEmailTXT  = template.RegisterMessagePlainText("messages/forgot_password_oob_email.txt")
	TemplateMessageForgotPasswordOOBEmailHTML = template.RegisterMessageHTML("messages/forgot_password_oob_email.html")

	TemplateWhatsappOTPCodeTXT = template.RegisterMessagePlainText("messages/whatsapp_otp_code.txt")

	TemplateMessageSendPasswordToExistingUserTXT       = template.RegisterMessagePlainText("messages/send_password_to_existing_user_email.txt")
	TemplateMessageSendPasswordToExistingUserEmailHTML = template.RegisterMessageHTML("messages/send_password_to_existing_user_email.html")

	TemplateMessageSendPasswordToNewUserTXT       = template.RegisterMessagePlainText("messages/send_password_to_new_user_email.txt")
	TemplateMessageSendPasswordToNewUserEmailHTML = template.RegisterMessageHTML("messages/send_password_to_new_user_email.html")
)
View Source
var (
	MessageVerification = &MessageSpec{
		MessageType:       MessageTypeVerification,
		Name:              SpecNameVerification,
		TXTEmailTemplate:  TemplateMessageVerificationEmailTXT,
		HTMLEmailTemplate: TemplateMessageVerificationEmailHTML,
		SMSTemplate:       TemplateMessageVerificationSMSTXT,
	}
	MessageSetupPrimaryOOB = &MessageSpec{
		MessageType:       MessageTypeSetupPrimaryOOB,
		Name:              SpecNameSetupPrimaryOOB,
		TXTEmailTemplate:  TemplateMessageSetupPrimaryOOBEmailTXT,
		HTMLEmailTemplate: TemplateMessageSetupPrimaryOOBEmailHTML,
		SMSTemplate:       TemplateMessageSetupPrimaryOOBSMSTXT,
	}
	MessageSetupPrimaryLoginLink = &MessageSpec{
		MessageType:       MessageTypeSetupPrimaryOOB,
		Name:              SpecNameSetupPrimaryLoginLink,
		TXTEmailTemplate:  TemplateMessageSetupPrimaryLoginLinkEmailTXT,
		HTMLEmailTemplate: TemplateMessageSetupPrimaryLoginLinkEmailHTML,
	}
	MessageSetupSecondaryOOB = &MessageSpec{
		MessageType:       MessageTypeSetupSecondaryOOB,
		Name:              SpecNameSetupSecondaryOOB,
		TXTEmailTemplate:  TemplateMessageSetupSecondaryOOBEmailTXT,
		HTMLEmailTemplate: TemplateMessageSetupSecondaryOOBEmailHTML,
		SMSTemplate:       TemplateMessageSetupSecondaryOOBSMSTXT,
	}
	MessageSetupSecondaryLoginLink = &MessageSpec{
		MessageType:       MessageTypeSetupSecondaryOOB,
		Name:              SpecNameSetupSecondaryLoginLink,
		TXTEmailTemplate:  TemplateMessageSetupSecondaryLoginLinkEmailTXT,
		HTMLEmailTemplate: TemplateMessageSetupSecondaryLoginLinkEmailHTML,
	}
	MessageAuthenticatePrimaryOOB = &MessageSpec{
		MessageType:       MessageTypeAuthenticatePrimaryOOB,
		Name:              SpecNameAuthenticatePrimaryOOB,
		TXTEmailTemplate:  TemplateMessageAuthenticatePrimaryOOBEmailTXT,
		HTMLEmailTemplate: TemplateMessageAuthenticatePrimaryOOBEmailHTML,
		SMSTemplate:       TemplateMessageAuthenticatePrimaryOOBSMSTXT,
	}
	MessageAuthenticatePrimaryLoginLink = &MessageSpec{
		MessageType:       MessageTypeAuthenticatePrimaryOOB,
		Name:              SpecNameAuthenticatePrimaryLoginLink,
		TXTEmailTemplate:  TemplateMessageAuthenticatePrimaryLoginLinkEmailTXT,
		HTMLEmailTemplate: TemplateMessageAuthenticatePrimaryLoginLinkEmailHTML,
	}
	MessageAuthenticateSecondaryOOB = &MessageSpec{
		MessageType:       MessageTypeAuthenticateSecondaryOOB,
		Name:              SpecNameAuthenticateSecondaryOOB,
		TXTEmailTemplate:  TemplateMessageAuthenticateSecondaryOOBEmailTXT,
		HTMLEmailTemplate: TemplateMessageAuthenticateSecondaryOOBEmailHTML,
		SMSTemplate:       TemplateMessageAuthenticateSecondaryOOBSMSTXT,
	}
	MessageAuthenticateSecondaryLoginLink = &MessageSpec{
		MessageType:       MessageTypeAuthenticateSecondaryOOB,
		Name:              SpecNameAuthenticateSecondaryLoginLink,
		TXTEmailTemplate:  TemplateMessageAuthenticateSecondaryLoginLinkEmailTXT,
		HTMLEmailTemplate: TemplateMessageAuthenticateSecondaryLoginLinkEmailHTML,
	}
	MessageForgotPasswordLink = &MessageSpec{
		MessageType:       MessageTypeForgotPassword,
		Name:              SpecNameForgotPassword,
		TXTEmailTemplate:  TemplateMessageForgotPasswordLinkEmailTXT,
		HTMLEmailTemplate: TemplateMessageForgotPasswordLinkEmailHTML,
		SMSTemplate:       TemplateMessageForgotPasswordLinkSMSTXT,
	}
	MessageForgotPasswordOOB = &MessageSpec{
		MessageType:       MessageTypeForgotPassword,
		Name:              SpecNameForgotPasswordOOB,
		TXTEmailTemplate:  TemplateMessageForgotPasswordOOBEmailTXT,
		HTMLEmailTemplate: TemplateMessageForgotPasswordOOBEmailHTML,
		SMSTemplate:       TemplateMessageForgotPasswordOOBSMSTXT,
	}
	MessageWhatsappCode = &MessageSpec{
		MessageType:      MessageTypeWhatsappCode,
		Name:             SpecNameWhatsappCode,
		WhatsappTemplate: TemplateWhatsappOTPCodeTXT,
	}
	MessageSendPasswordToExistingUser = &MessageSpec{
		MessageType:       MessageTypeSendPasswordToExistingUser,
		Name:              SpecNameSendPasswordToExistingUser,
		TXTEmailTemplate:  TemplateMessageSendPasswordToExistingUserTXT,
		HTMLEmailTemplate: TemplateMessageSendPasswordToExistingUserEmailHTML,
	}
	MessageSendPasswordToNewUser = &MessageSpec{
		MessageType:       MessageTypeSendPasswordToNewUser,
		Name:              SpecNameSendPasswordToNewUser,
		TXTEmailTemplate:  TemplateMessageSendPasswordToNewUserTXT,
		HTMLEmailTemplate: TemplateMessageSendPasswordToNewUserEmailHTML,
	}
)
View Source
var DependencySet = wire.NewSet(
	wire.Struct(new(Service), "*"),
)

Functions

This section is empty.

Types

type EmailMessageData

type EmailMessageData struct {
	Sender   string
	ReplyTo  string
	Subject  string
	HTMLBody *template.RenderResult
	TextBody *template.RenderResult
}

type MessageSpec

type MessageSpec struct {
	MessageType       MessageType
	Name              SpecName
	TXTEmailTemplate  *template.MessagePlainText
	HTMLEmailTemplate *template.MessageHTML
	SMSTemplate       *template.MessagePlainText
	WhatsappTemplate  *template.MessagePlainText
}

type MessageType

type MessageType string
const (
	MessageTypeVerification               MessageType = "verification"
	MessageTypeSetupPrimaryOOB            MessageType = "setup-primary-oob"
	MessageTypeSetupSecondaryOOB          MessageType = "setup-secondary-oob"
	MessageTypeAuthenticatePrimaryOOB     MessageType = "authenticate-primary-oob"
	MessageTypeAuthenticateSecondaryOOB   MessageType = "authenticate-secondary-oob"
	MessageTypeForgotPassword             MessageType = "forgot-password"
	MessageTypeSendPasswordToExistingUser MessageType = "send-password-to-existing-user"
	MessageTypeSendPasswordToNewUser      MessageType = "send-password-to-new-user"
	MessageTypeWhatsappCode               MessageType = "whatsapp-code"
)

type PartialTemplateVariables

type PartialTemplateVariables struct {
	// OTP
	Email string
	Phone string
	Code  string
	URL   string
	Link  string
	Host  string

	// OTP Additional context
	HasPassword bool

	// Forgot password
	Password string
}

type PreparedTemplateVariables

type PreparedTemplateVariables struct {
	AppName        string
	ClientID       string
	Code           string
	Email          string
	HasPassword    bool
	Host           string
	Link           string
	Password       string
	Phone          string
	State          string
	StaticAssetURL func(id string) (url string, err error)
	UILocales      string
	URL            string
	XState         string
}

type SMSMessageData

type SMSMessageData struct {
	Sender                    string
	Body                      *template.RenderResult
	PreparedTemplateVariables *PreparedTemplateVariables
}

type Service

type Service struct {
	TemplateEngine *template.Engine
	StaticAssets   StaticAssetResolver
	// contains filtered or unexported fields
}

func (*Service) EmailMessageData

func (s *Service) EmailMessageData(ctx context.Context, msg *MessageSpec, variables *PartialTemplateVariables) (*EmailMessageData, error)

func (*Service) GetSenderForTestEmail

func (s *Service) GetSenderForTestEmail(ctx context.Context) (sender string, err error)

func (*Service) HasKey

func (s *Service) HasKey(ctx context.Context, key string) (bool, error)

func (*Service) RenderText

func (s *Service) RenderText(ctx context.Context, key string, args interface{}) (string, error)

func (*Service) SMSMessageData

func (s *Service) SMSMessageData(ctx context.Context, msg *MessageSpec, variables *PartialTemplateVariables) (*SMSMessageData, error)

func (*Service) WhatsappMessageData

func (s *Service) WhatsappMessageData(ctx context.Context, language string, msg *MessageSpec, variables *PartialTemplateVariables) (*WhatsappMessageData, error)

type SpecName

type SpecName string
const (
	SpecNameVerification                   SpecName = "verification"
	SpecNameSetupPrimaryOOB                SpecName = "setup-primary-oob"
	SpecNameSetupPrimaryLoginLink          SpecName = "setup-primary-login-link"
	SpecNameSetupSecondaryOOB              SpecName = "setup-secondary-oob"
	SpecNameSetupSecondaryLoginLink        SpecName = "setup-secondary-login-link"
	SpecNameAuthenticatePrimaryOOB         SpecName = "authenticate-primary-oob"
	SpecNameAuthenticatePrimaryLoginLink   SpecName = "authenticate-primary-login-link"
	SpecNameAuthenticateSecondaryOOB       SpecName = "authenticate-secondary-oob"
	SpecNameAuthenticateSecondaryLoginLink SpecName = "authenticate-secondary-login-link"
	SpecNameForgotPassword                 SpecName = "forgot-password"
	SpecNameForgotPasswordOOB              SpecName = "forgot-password-oob"
	SpecNameChangePassword                 SpecName = "change-password"
	SpecNameWhatsappCode                   SpecName = "whatsapp-code"
	SpecNameSendPasswordToExistingUser     SpecName = "send-password-to-existing-user"
	SpecNameSendPasswordToNewUser          SpecName = "send-password-to-new-user"
)

type StaticAssetResolver

type StaticAssetResolver interface {
	StaticAssetURL(ctx context.Context, id string) (url string, err error)
}

type WhatsappMessageData

type WhatsappMessageData struct {
	Body *template.RenderResult
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL