zitadel/internal/api/grpc/admin/text_converter.go
Fabi fbc75d89b2
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>
2021-02-10 10:48:40 +01:00

67 lines
1.9 KiB
Go

package admin
import (
iam_model "github.com/caos/zitadel/internal/iam/model"
"github.com/caos/zitadel/internal/v2/domain"
"github.com/caos/zitadel/pkg/grpc/admin"
"google.golang.org/protobuf/types/known/timestamppb"
)
func textToDomain(text *admin.DefaultMailTextUpdate) *domain.MailText {
return &domain.MailText{
MailTextType: text.MailTextType,
Language: text.Language,
Title: text.Title,
PreHeader: text.PreHeader,
Subject: text.Subject,
Greeting: text.Greeting,
Text: text.Text,
ButtonText: text.ButtonText,
}
}
func textFromDomain(text *domain.MailText) *admin.DefaultMailText {
return &admin.DefaultMailText{
MailTextType: text.MailTextType,
Language: text.Language,
Title: text.Title,
PreHeader: text.PreHeader,
Subject: text.Subject,
Greeting: text.Greeting,
Text: text.Text,
ButtonText: text.ButtonText,
CreationDate: timestamppb.New(text.CreationDate),
ChangeDate: timestamppb.New(text.ChangeDate),
}
}
func textsViewFromModel(textsin *iam_model.MailTextsView) *admin.DefaultMailTextsView {
return &admin.DefaultMailTextsView{
Texts: textsViewToModel(textsin.Texts),
}
}
func textsViewToModel(queries []*iam_model.MailTextView) []*admin.DefaultMailTextView {
modelQueries := make([]*admin.DefaultMailTextView, len(queries))
for i, query := range queries {
modelQueries[i] = textViewFromModel(query)
}
return modelQueries
}
func textViewFromModel(text *iam_model.MailTextView) *admin.DefaultMailTextView {
return &admin.DefaultMailTextView{
MailTextType: text.MailTextType,
Language: text.Language,
Title: text.Title,
PreHeader: text.PreHeader,
Subject: text.Subject,
Greeting: text.Greeting,
Text: text.Text,
ButtonText: text.ButtonText,
CreationDate: timestamppb.New(text.CreationDate),
ChangeDate: timestamppb.New(text.ChangeDate),
}
}