zitadel/internal/api/grpc/admin/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.3 KiB
Go

package admin
import (
"github.com/caos/logging"
iam_model "github.com/caos/zitadel/internal/iam/model"
"github.com/caos/zitadel/pkg/grpc/admin"
"github.com/golang/protobuf/ptypes"
)
func templateToModel(policy *admin.DefaultMailTemplateUpdate) *iam_model.MailTemplate {
return &iam_model.MailTemplate{
Template: policy.Template,
}
}
func templateFromModel(policy *iam_model.MailTemplate) *admin.DefaultMailTemplate {
creationDate, err := ptypes.TimestampProto(policy.CreationDate)
logging.Log("ADMIN-CAA7T").OnError(err).Debug("date parse failed")
changeDate, err := ptypes.TimestampProto(policy.ChangeDate)
logging.Log("ADMIN-H52Zx").OnError(err).Debug("date parse failed")
return &admin.DefaultMailTemplate{
Template: policy.Template,
CreationDate: creationDate,
ChangeDate: changeDate,
}
}
func templateViewFromModel(policy *iam_model.MailTemplateView) *admin.DefaultMailTemplateView {
creationDate, err := ptypes.TimestampProto(policy.CreationDate)
logging.Log("ADMIN-yWFs5").OnError(err).Debug("date parse failed")
changeDate, err := ptypes.TimestampProto(policy.ChangeDate)
logging.Log("ADMIN-JRpIO").OnError(err).Debug("date parse failed")
return &admin.DefaultMailTemplateView{
Template: policy.Template,
CreationDate: creationDate,
ChangeDate: changeDate,
}
}