mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:17:32 +00:00
fix: Get Label policy in notifications (#2923)
This commit is contained in:
@@ -3,20 +3,18 @@ package templates
|
||||
import (
|
||||
"fmt"
|
||||
"html"
|
||||
"strings"
|
||||
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/i18n"
|
||||
iam_model "github.com/caos/zitadel/internal/iam/model"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultFont = "http://fonts.googleapis.com/css?family=Lato:200,300,400,600"
|
||||
defaultFontFamily = "-apple-system, BlinkMacSystemFont, Segoe UI, Lato, Arial, Helvetica, sans-serif"
|
||||
defaultLogo = "https://static.zitadel.ch/zitadel-logo-dark@3x.png"
|
||||
defaultFontColor = "#22292f"
|
||||
defaultBackgroundColor = "#fafafa"
|
||||
defaultPrimaryColor = "#5282C1"
|
||||
DefaultFont = "http://fonts.googleapis.com/css?family=Lato:200,300,400,600"
|
||||
DefaultFontFamily = "-apple-system, BlinkMacSystemFont, Segoe UI, Lato, Arial, Helvetica, sans-serif"
|
||||
DefaultLogo = "https://static.zitadel.ch/zitadel-logo-dark@3x.png"
|
||||
DefaultFontColor = "#22292f"
|
||||
DefaultBackgroundColor = "#fafafa"
|
||||
DefaultPrimaryColor = "#5282C1"
|
||||
)
|
||||
|
||||
type TemplateData struct {
|
||||
@@ -47,39 +45,3 @@ func (data *TemplateData) Translate(translator *i18n.Translator, msgType string,
|
||||
data.ButtonText = translator.Localize(fmt.Sprintf("%s.%s", msgType, domain.MessageButtonText), args, langs...)
|
||||
data.FooterText = translator.Localize(fmt.Sprintf("%s.%s", msgType, domain.MessageFooterText), args, langs...)
|
||||
}
|
||||
|
||||
func GetTemplateData(translator *i18n.Translator, translateArgs map[string]interface{}, apiDomain, href, msgType, lang string, policy *iam_model.LabelPolicyView) TemplateData {
|
||||
templateData := TemplateData{
|
||||
Href: href,
|
||||
PrimaryColor: defaultPrimaryColor,
|
||||
BackgroundColor: defaultBackgroundColor,
|
||||
FontColor: defaultFontColor,
|
||||
LogoURL: defaultLogo,
|
||||
FontURL: defaultFont,
|
||||
FontFamily: defaultFontFamily,
|
||||
IncludeFooter: false,
|
||||
}
|
||||
templateData.Translate(translator, msgType, translateArgs, lang)
|
||||
if policy.PrimaryColor != "" {
|
||||
templateData.PrimaryColor = policy.PrimaryColor
|
||||
}
|
||||
if policy.BackgroundColor != "" {
|
||||
templateData.BackgroundColor = policy.BackgroundColor
|
||||
}
|
||||
if policy.FontColor != "" {
|
||||
templateData.FontColor = policy.FontColor
|
||||
}
|
||||
if apiDomain == "" {
|
||||
return templateData
|
||||
}
|
||||
templateData.LogoURL = ""
|
||||
if policy.LogoURL != "" {
|
||||
templateData.LogoURL = fmt.Sprintf("%s/assets/v1/%s/%s", apiDomain, policy.AggregateID, policy.LogoURL)
|
||||
}
|
||||
if policy.FontURL != "" {
|
||||
split := strings.Split(policy.FontURL, "/")
|
||||
templateData.FontFamily = split[len(split)-1] + "," + defaultFontFamily
|
||||
templateData.FontURL = fmt.Sprintf("%s/assets/v1/%s/%s", apiDomain, policy.AggregateID, policy.FontURL)
|
||||
}
|
||||
return templateData
|
||||
}
|
||||
|
Reference in New Issue
Block a user