mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-10 22:03:40 +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
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package management
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/pkg/grpc/management"
|
|
"github.com/golang/protobuf/ptypes/empty"
|
|
)
|
|
|
|
func (s *Server) GetMailTexts(ctx context.Context, _ *empty.Empty) (*management.MailTextsView, error) {
|
|
result, err := s.org.GetMailTexts(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return mailTextsViewFromModel(result.Texts), nil
|
|
}
|
|
|
|
func (s *Server) GetDefaultMailTexts(ctx context.Context, _ *empty.Empty) (*management.MailTextsView, error) {
|
|
result, err := s.org.GetDefaultMailTexts(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return mailTextsViewFromModel(result.Texts), nil
|
|
}
|
|
|
|
func (s *Server) CreateMailText(ctx context.Context, mailText *management.MailTextUpdate) (*management.MailText, error) {
|
|
result, err := s.org.AddMailText(ctx, mailTextRequestToModel(mailText))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return mailTextFromModel(result), nil
|
|
}
|
|
|
|
func (s *Server) UpdateMailText(ctx context.Context, mailText *management.MailTextUpdate) (*management.MailText, error) {
|
|
result, err := s.org.ChangeMailText(ctx, mailTextRequestToModel(mailText))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return mailTextFromModel(result), nil
|
|
}
|
|
|
|
func (s *Server) RemoveMailText(ctx context.Context, mailText *management.MailTextRemove) (*empty.Empty, error) {
|
|
err := s.org.RemoveMailText(ctx, mailTextRemoveToModel(mailText))
|
|
return &empty.Empty{}, err
|
|
}
|