feat: mail tempaltes/texts and step 10 (#1266)

* feat: mail template/text events

* feat: mail template/text events

* feat: mail template/text on iam and org

* feat: setup step 10

* fix: add template event

* fix: add unique constraints

* Update internal/static/i18n/de.yaml

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/static/i18n/de.yaml

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/static/i18n/de.yaml

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/static/i18n/de.yaml

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/v2/command/iam_policy_mail_template.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/v2/command/org_policy_mail_text.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/v2/command/iam_policy_mail_template.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/v2/command/iam_policy_mail_text.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/v2/command/iam_policy_mail_text.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/v2/command/org_policy_mail_template.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/v2/command/org_policy_mail_template.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/v2/command/org_policy_mail_text.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* fix: org iam policy

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Fabi
2021-02-10 10:48:40 +01:00
committed by GitHub
parent b0bcc13a92
commit fbc75d89b2
48 changed files with 1689 additions and 287 deletions

View File

@@ -65,7 +65,7 @@ func (s *Server) GetOrgIamPolicy(ctx context.Context, in *admin.OrgIamPolicyID)
}
func (s *Server) CreateOrgIamPolicy(ctx context.Context, in *admin.OrgIamPolicyRequest) (_ *admin.OrgIamPolicy, err error) {
policy, err := s.command.AddOrgIAMPolicy(ctx, orgIAMPolicyRequestToDomain(in))
policy, err := s.command.AddOrgIAMPolicy(ctx, in.OrgId, orgIAMPolicyRequestToDomain(in))
if err != nil {
return nil, err
}
@@ -73,7 +73,7 @@ func (s *Server) CreateOrgIamPolicy(ctx context.Context, in *admin.OrgIamPolicyR
}
func (s *Server) UpdateOrgIamPolicy(ctx context.Context, in *admin.OrgIamPolicyRequest) (_ *admin.OrgIamPolicy, err error) {
policy, err := s.command.ChangeOrgIAMPolicy(ctx, orgIAMPolicyRequestToDomain(in))
policy, err := s.command.ChangeOrgIAMPolicy(ctx, in.OrgId, orgIAMPolicyRequestToDomain(in))
if err != nil {
return nil, err
}

View File

@@ -16,9 +16,9 @@ func (s *Server) GetDefaultMailTemplate(ctx context.Context, _ *empty.Empty) (*a
}
func (s *Server) UpdateDefaultMailTemplate(ctx context.Context, policy *admin.DefaultMailTemplateUpdate) (*admin.DefaultMailTemplate, error) {
result, err := s.iam.ChangeDefaultMailTemplate(ctx, templateToModel(policy))
result, err := s.command.ChangeDefaultMailTemplate(ctx, templateToDomain(policy))
if err != nil {
return nil, err
}
return templateFromModel(result), nil
return templateFromDomain(result), nil
}

View File

@@ -1,42 +1,30 @@
package admin
import (
"github.com/caos/logging"
iam_model "github.com/caos/zitadel/internal/iam/model"
"github.com/caos/zitadel/internal/v2/domain"
"github.com/caos/zitadel/pkg/grpc/admin"
"github.com/golang/protobuf/ptypes"
"google.golang.org/protobuf/types/known/timestamppb"
)
func templateToModel(policy *admin.DefaultMailTemplateUpdate) *iam_model.MailTemplate {
return &iam_model.MailTemplate{
func templateToDomain(policy *admin.DefaultMailTemplateUpdate) *domain.MailTemplate {
return &domain.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")
func templateFromDomain(policy *domain.MailTemplate) *admin.DefaultMailTemplate {
return &admin.DefaultMailTemplate{
Template: policy.Template,
CreationDate: creationDate,
ChangeDate: changeDate,
CreationDate: timestamppb.New(policy.CreationDate),
ChangeDate: timestamppb.New(policy.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,
CreationDate: timestamppb.New(policy.CreationDate),
ChangeDate: timestamppb.New(policy.ChangeDate),
}
}

View File

@@ -24,9 +24,9 @@ func (s *Server) GetDefaultMailText(ctx context.Context, textType string, langua
}
func (s *Server) UpdateDefaultMailText(ctx context.Context, text *admin.DefaultMailTextUpdate) (*admin.DefaultMailText, error) {
result, err := s.iam.ChangeDefaultMailText(ctx, textToModel(text))
result, err := s.command.ChangeDefaultMailText(ctx, textToDomain(text))
if err != nil {
return nil, err
}
return textFromModel(result), nil
return textFromDomain(result), nil
}

View File

@@ -1,14 +1,14 @@
package admin
import (
"github.com/caos/logging"
iam_model "github.com/caos/zitadel/internal/iam/model"
"github.com/caos/zitadel/internal/v2/domain"
"github.com/caos/zitadel/pkg/grpc/admin"
"github.com/golang/protobuf/ptypes"
"google.golang.org/protobuf/types/known/timestamppb"
)
func textToModel(text *admin.DefaultMailTextUpdate) *iam_model.MailText {
return &iam_model.MailText{
func textToDomain(text *admin.DefaultMailTextUpdate) *domain.MailText {
return &domain.MailText{
MailTextType: text.MailTextType,
Language: text.Language,
Title: text.Title,
@@ -20,13 +20,7 @@ func textToModel(text *admin.DefaultMailTextUpdate) *iam_model.MailText {
}
}
func textFromModel(text *iam_model.MailText) *admin.DefaultMailText {
creationDate, err := ptypes.TimestampProto(text.CreationDate)
logging.Log("ADMIN-Jlzsj").OnError(err).Debug("date parse failed")
changeDate, err := ptypes.TimestampProto(text.ChangeDate)
logging.Log("ADMIN-mw5b8").OnError(err).Debug("date parse failed")
func textFromDomain(text *domain.MailText) *admin.DefaultMailText {
return &admin.DefaultMailText{
MailTextType: text.MailTextType,
Language: text.Language,
@@ -36,8 +30,8 @@ func textFromModel(text *iam_model.MailText) *admin.DefaultMailText {
Greeting: text.Greeting,
Text: text.Text,
ButtonText: text.ButtonText,
CreationDate: creationDate,
ChangeDate: changeDate,
CreationDate: timestamppb.New(text.CreationDate),
ChangeDate: timestamppb.New(text.ChangeDate),
}
}
@@ -57,12 +51,6 @@ func textsViewToModel(queries []*iam_model.MailTextView) []*admin.DefaultMailTex
}
func textViewFromModel(text *iam_model.MailTextView) *admin.DefaultMailTextView {
creationDate, err := ptypes.TimestampProto(text.CreationDate)
logging.Log("ADMIN-7RyJc").OnError(err).Debug("date parse failed")
changeDate, err := ptypes.TimestampProto(text.ChangeDate)
logging.Log("ADMIN-fTFgY").OnError(err).Debug("date parse failed")
return &admin.DefaultMailTextView{
MailTextType: text.MailTextType,
Language: text.Language,
@@ -72,7 +60,7 @@ func textViewFromModel(text *iam_model.MailTextView) *admin.DefaultMailTextView
Greeting: text.Greeting,
Text: text.Text,
ButtonText: text.ButtonText,
CreationDate: creationDate,
ChangeDate: changeDate,
CreationDate: timestamppb.New(text.CreationDate),
ChangeDate: timestamppb.New(text.ChangeDate),
}
}