zitadel/internal/api/grpc/management/mail_template_converter.go
Michael Waeger f2a32871a7
feat: e-mail templates (#1158)
* 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
2021-01-18 14:17:22 +01:00

43 lines
1.4 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 mailTemplateRequestToModel(mailTemplate *management.MailTemplateUpdate) *iam_model.MailTemplate {
return &iam_model.MailTemplate{
Template: mailTemplate.Template,
}
}
func mailTemplateFromModel(mailTemplate *iam_model.MailTemplate) *management.MailTemplate {
creationDate, err := ptypes.TimestampProto(mailTemplate.CreationDate)
logging.Log("MANAG-ULKZ6").OnError(err).Debug("date parse failed")
changeDate, err := ptypes.TimestampProto(mailTemplate.ChangeDate)
logging.Log("MANAG-451rI").OnError(err).Debug("date parse failed")
return &management.MailTemplate{
Template: mailTemplate.Template,
CreationDate: creationDate,
ChangeDate: changeDate,
}
}
func mailTemplateViewFromModel(mailTemplate *iam_model.MailTemplateView) *management.MailTemplateView {
creationDate, err := ptypes.TimestampProto(mailTemplate.CreationDate)
logging.Log("MANAG-koQnB").OnError(err).Debug("date parse failed")
changeDate, err := ptypes.TimestampProto(mailTemplate.ChangeDate)
logging.Log("MANAG-ToDhD").OnError(err).Debug("date parse failed")
return &management.MailTemplateView{
Default: mailTemplate.Default,
Template: mailTemplate.Template,
CreationDate: creationDate,
ChangeDate: changeDate,
}
}