mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-10 23:43: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
54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
package view
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/errors"
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
|
"github.com/caos/zitadel/internal/iam/repository/view"
|
|
"github.com/caos/zitadel/internal/iam/repository/view/model"
|
|
global_view "github.com/caos/zitadel/internal/view/repository"
|
|
)
|
|
|
|
const (
|
|
mailTemplateTable = "management.mail_templates"
|
|
)
|
|
|
|
func (v *View) MailTemplateByAggregateID(aggregateID string) (*model.MailTemplateView, error) {
|
|
return view.GetMailTemplateByAggregateID(v.Db, mailTemplateTable, aggregateID)
|
|
}
|
|
|
|
func (v *View) PutMailTemplate(template *model.MailTemplateView, event *models.Event) error {
|
|
err := view.PutMailTemplate(v.Db, mailTemplateTable, template)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return v.ProcessedMailTemplateSequence(event)
|
|
}
|
|
|
|
func (v *View) DeleteMailTemplate(aggregateID string, event *models.Event) error {
|
|
err := view.DeleteMailTemplate(v.Db, mailTemplateTable, aggregateID)
|
|
if err != nil && !errors.IsNotFound(err) {
|
|
return err
|
|
}
|
|
return v.ProcessedMailTemplateSequence(event)
|
|
}
|
|
|
|
func (v *View) GetLatestMailTemplateSequence(aggregateType string) (*global_view.CurrentSequence, error) {
|
|
return v.latestSequence(mailTemplateTable, aggregateType)
|
|
}
|
|
|
|
func (v *View) ProcessedMailTemplateSequence(event *models.Event) error {
|
|
return v.saveCurrentSequence(mailTemplateTable, event)
|
|
}
|
|
|
|
func (v *View) UpdateMailTemplateSpoolerRunTimestamp() error {
|
|
return v.updateSpoolerRunSequence(mailTemplateTable)
|
|
}
|
|
|
|
func (v *View) GetLatestMailTemplateFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
|
return v.latestFailedEvent(mailTemplateTable, sequence)
|
|
}
|
|
|
|
func (v *View) ProcessedMailTemplateFailedEvent(failedEvent *global_view.FailedEvent) error {
|
|
return v.saveFailedEvent(failedEvent)
|
|
}
|