mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 04:02:08 +00:00
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
This commit is contained in:
@@ -16,6 +16,7 @@ const (
|
||||
Step7
|
||||
Step8
|
||||
Step9
|
||||
Step10
|
||||
//StepCount marks the the length of possible steps (StepCount-1 == last possible step)
|
||||
StepCount
|
||||
)
|
||||
@@ -34,6 +35,8 @@ type IAM struct {
|
||||
DefaultPasswordComplexityPolicy *PasswordComplexityPolicy
|
||||
DefaultPasswordAgePolicy *PasswordAgePolicy
|
||||
DefaultPasswordLockoutPolicy *PasswordLockoutPolicy
|
||||
DefaultMailTemplate *MailTemplate
|
||||
DefaultMailTexts []*MailText
|
||||
}
|
||||
|
||||
func (iam *IAM) GetMember(userID string) (int, *IAMMember) {
|
||||
@@ -53,3 +56,12 @@ func (iam *IAM) GetIDP(idpID string) (int, *IDPConfig) {
|
||||
}
|
||||
return -1, nil
|
||||
}
|
||||
|
||||
func (iam *IAM) GetDefaultMailText(mailTextType string, language string) (int, *MailText) {
|
||||
for i, m := range iam.DefaultMailTexts {
|
||||
if m.MailTextType == mailTextType && m.Language == language {
|
||||
return i, m
|
||||
}
|
||||
}
|
||||
return -1, nil
|
||||
}
|
||||
|
||||
17
internal/iam/model/mail_template.go
Normal file
17
internal/iam/model/mail_template.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/caos/zitadel/internal/eventstore/models"
|
||||
)
|
||||
|
||||
type MailTemplate struct {
|
||||
models.ObjectRoot
|
||||
|
||||
State PolicyState
|
||||
Default bool
|
||||
Template []byte
|
||||
}
|
||||
|
||||
func (p *MailTemplate) IsValid() bool {
|
||||
return p.ObjectRoot.AggregateID != ""
|
||||
}
|
||||
47
internal/iam/model/mail_template_view.go
Normal file
47
internal/iam/model/mail_template_view.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/caos/zitadel/internal/model"
|
||||
)
|
||||
|
||||
type MailTemplateView struct {
|
||||
AggregateID string
|
||||
Template []byte
|
||||
Default bool
|
||||
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
type MailTemplateSearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn MailTemplateSearchKey
|
||||
Asc bool
|
||||
Queries []*MailTemplateSearchQuery
|
||||
}
|
||||
|
||||
type MailTemplateSearchKey int32
|
||||
|
||||
const (
|
||||
MailTemplateSearchKeyUnspecified MailTemplateSearchKey = iota
|
||||
MailTemplateSearchKeyAggregateID
|
||||
)
|
||||
|
||||
type MailTemplateSearchQuery struct {
|
||||
Key MailTemplateSearchKey
|
||||
Method model.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type MailTemplateSearchResponse struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
TotalResult uint64
|
||||
Result []*MailTemplateView
|
||||
Sequence uint64
|
||||
Timestamp time.Time
|
||||
}
|
||||
28
internal/iam/model/mail_text.go
Normal file
28
internal/iam/model/mail_text.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/caos/zitadel/internal/eventstore/models"
|
||||
)
|
||||
|
||||
type MailTexts struct {
|
||||
Texts []*MailText
|
||||
Default bool
|
||||
}
|
||||
type MailText struct {
|
||||
models.ObjectRoot
|
||||
|
||||
State PolicyState
|
||||
Default bool
|
||||
MailTextType string
|
||||
Language string
|
||||
Title string
|
||||
PreHeader string
|
||||
Subject string
|
||||
Greeting string
|
||||
Text string
|
||||
ButtonText string
|
||||
}
|
||||
|
||||
func (p *MailText) IsValid() bool {
|
||||
return p.ObjectRoot.AggregateID != ""
|
||||
}
|
||||
60
internal/iam/model/mail_text_view.go
Normal file
60
internal/iam/model/mail_text_view.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/caos/zitadel/internal/model"
|
||||
)
|
||||
|
||||
type MailTextsView struct {
|
||||
Texts []*MailTextView
|
||||
Default bool
|
||||
}
|
||||
type MailTextView struct {
|
||||
AggregateID string
|
||||
MailTextType string
|
||||
Language string
|
||||
Title string
|
||||
PreHeader string
|
||||
Subject string
|
||||
Greeting string
|
||||
Text string
|
||||
ButtonText string
|
||||
Default bool
|
||||
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
type MailTextSearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn MailTextSearchKey
|
||||
Asc bool
|
||||
Queries []*MailTextSearchQuery
|
||||
}
|
||||
|
||||
type MailTextSearchKey int32
|
||||
|
||||
const (
|
||||
MailTextSearchKeyUnspecified MailTextSearchKey = iota
|
||||
MailTextSearchKeyAggregateID
|
||||
MailTextSearchKeyMailTextType
|
||||
MailTextSearchKeyLanguage
|
||||
)
|
||||
|
||||
type MailTextSearchQuery struct {
|
||||
Key MailTextSearchKey
|
||||
Method model.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type MailTextSearchResponse struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
TotalResult uint64
|
||||
Result []*MailTextView
|
||||
Sequence uint64
|
||||
Timestamp time.Time
|
||||
}
|
||||
Reference in New Issue
Block a user