zitadel/internal/api/grpc/management/mail_template.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

46 lines
1.4 KiB
Go

package management
import (
"context"
"github.com/caos/zitadel/pkg/grpc/management"
"github.com/golang/protobuf/ptypes/empty"
)
func (s *Server) GetMailTemplate(ctx context.Context, _ *empty.Empty) (*management.MailTemplateView, error) {
result, err := s.org.GetMailTemplate(ctx)
if err != nil {
return nil, err
}
return mailTemplateViewFromModel(result), nil
}
func (s *Server) GetDefaultMailTemplate(ctx context.Context, _ *empty.Empty) (*management.MailTemplateView, error) {
result, err := s.org.GetDefaultMailTemplate(ctx)
if err != nil {
return nil, err
}
return mailTemplateViewFromModel(result), nil
}
func (s *Server) CreateMailTemplate(ctx context.Context, template *management.MailTemplateUpdate) (*management.MailTemplate, error) {
result, err := s.org.AddMailTemplate(ctx, mailTemplateRequestToModel(template))
if err != nil {
return nil, err
}
return mailTemplateFromModel(result), nil
}
func (s *Server) UpdateMailTemplate(ctx context.Context, template *management.MailTemplateUpdate) (*management.MailTemplate, error) {
result, err := s.org.ChangeMailTemplate(ctx, mailTemplateRequestToModel(template))
if err != nil {
return nil, err
}
return mailTemplateFromModel(result), nil
}
func (s *Server) RemoveMailTemplate(ctx context.Context, _ *empty.Empty) (*empty.Empty, error) {
err := s.org.RemoveMailTemplate(ctx)
return &empty.Empty{}, err
}