mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-10 15:33:41 +00:00
f2a32871a7
* View definition added * Get templates and texts from the database. * Fill in texts in templates * Fill in texts in templates * Client API added * Weekly backup * Weekly backup * Daily backup * Weekly backup * Tests added * Corrections from merge branch * Fixes from pull request review
83 lines
2.5 KiB
Go
83 lines
2.5 KiB
Go
package management
|
|
|
|
import (
|
|
"github.com/caos/logging"
|
|
iam_model "github.com/caos/zitadel/internal/iam/model"
|
|
"github.com/caos/zitadel/pkg/grpc/management"
|
|
"github.com/golang/protobuf/ptypes"
|
|
)
|
|
|
|
func mailTextRequestToModel(mailText *management.MailTextUpdate) *iam_model.MailText {
|
|
return &iam_model.MailText{
|
|
MailTextType: mailText.MailTextType,
|
|
Language: mailText.Language,
|
|
Title: mailText.Title,
|
|
PreHeader: mailText.PreHeader,
|
|
Subject: mailText.Subject,
|
|
Greeting: mailText.Greeting,
|
|
Text: mailText.Text,
|
|
ButtonText: mailText.ButtonText,
|
|
}
|
|
}
|
|
|
|
func mailTextRemoveToModel(mailText *management.MailTextRemove) *iam_model.MailText {
|
|
return &iam_model.MailText{
|
|
MailTextType: mailText.MailTextType,
|
|
Language: mailText.Language,
|
|
}
|
|
}
|
|
|
|
func mailTextFromModel(mailText *iam_model.MailText) *management.MailText {
|
|
creationDate, err := ptypes.TimestampProto(mailText.CreationDate)
|
|
logging.Log("MANAG-ULKZ6").OnError(err).Debug("date parse failed")
|
|
|
|
changeDate, err := ptypes.TimestampProto(mailText.ChangeDate)
|
|
logging.Log("MANAG-451rI").OnError(err).Debug("date parse failed")
|
|
|
|
return &management.MailText{
|
|
MailTextType: mailText.MailTextType,
|
|
Language: mailText.Language,
|
|
Title: mailText.Title,
|
|
PreHeader: mailText.PreHeader,
|
|
Subject: mailText.Subject,
|
|
Greeting: mailText.Greeting,
|
|
Text: mailText.Text,
|
|
ButtonText: mailText.ButtonText,
|
|
CreationDate: creationDate,
|
|
ChangeDate: changeDate,
|
|
}
|
|
}
|
|
|
|
func mailTextsViewFromModel(queries []*iam_model.MailTextView) *management.MailTextsView {
|
|
modelQueries := make([]*management.MailTextView, len(queries))
|
|
for i, query := range queries {
|
|
modelQueries[i] = mailTextViewFromModel(query)
|
|
}
|
|
|
|
return &management.MailTextsView{
|
|
Texts: modelQueries,
|
|
}
|
|
}
|
|
|
|
func mailTextViewFromModel(mailText *iam_model.MailTextView) *management.MailTextView {
|
|
creationDate, err := ptypes.TimestampProto(mailText.CreationDate)
|
|
logging.Log("MANAG-koQnB").OnError(err).Debug("date parse failed")
|
|
|
|
changeDate, err := ptypes.TimestampProto(mailText.ChangeDate)
|
|
logging.Log("MANAG-ToDhD").OnError(err).Debug("date parse failed")
|
|
|
|
return &management.MailTextView{
|
|
Default: mailText.Default,
|
|
MailTextType: mailText.MailTextType,
|
|
Language: mailText.Language,
|
|
Title: mailText.Title,
|
|
PreHeader: mailText.PreHeader,
|
|
Subject: mailText.Subject,
|
|
Greeting: mailText.Greeting,
|
|
Text: mailText.Text,
|
|
ButtonText: mailText.ButtonText,
|
|
CreationDate: creationDate,
|
|
ChangeDate: changeDate,
|
|
}
|
|
}
|