mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
d8e42744b4
* fix: move eventstore pkgs * fix: move eventstore pkgs * fix: remove v2 view * fix: remove v2 view
72 lines
2.2 KiB
Go
72 lines
2.2 KiB
Go
package management
|
|
|
|
import (
|
|
"github.com/caos/logging"
|
|
"github.com/caos/zitadel/internal/domain"
|
|
iam_model "github.com/caos/zitadel/internal/iam/model"
|
|
"github.com/caos/zitadel/pkg/grpc/management"
|
|
"github.com/golang/protobuf/ptypes"
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
)
|
|
|
|
func mailTextRequestToDomain(mailText *management.MailTextUpdate) *domain.MailText {
|
|
return &domain.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 mailTextFromDoamin(mailText *domain.MailText) *management.MailText {
|
|
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: timestamppb.New(mailText.CreationDate),
|
|
ChangeDate: timestamppb.New(mailText.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,
|
|
}
|
|
}
|