mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 12:27:59 +00:00
d229da6af7
* feat: smtp templates poc * feat: add isActive & ProviderType to SMTP backend * feat: change providertype to uint32 and fix tests * feat: minimal smtp provider component * feat: woking on diiferent providers * feat: keep working on providers * feat: initial stepper for new provider * fix: settings list and working on stepper * feat: step 1 and 2 form inputs * feat: starter for smtp test step * fix: misspelled SMPT * fix: remove tests for now * feat: add tls toggle remove old google provider * feat: working on add smtp and table * fix: duplicated identifiers * fix: settings list * fix: add missing smtp config properties * fix: add configID to smtp config table * fix: working on listproviders * feat: working in listSMTPConfigs * fix: add count to listsmtpconfigs * fix: getting empty results from listSMTPConfigs * feat: table now shows real data * fix: remaining styles for smtp-table * fix: remove old notification-smtp-provider-component * feat: delete smtp configuration * feat: deactivate smtp config * feat: replace isActive with state for smtp config * feat: activate smtp config * fix: remaining errors after main merge * fix: list smtp providers panic and material mdc * feat: refactor to only one provider component * feat: current provider details view * fix: refactor AddSMTPConfig and ChangeSMTPConfig * fix: smtp config reduce issue * fix: recover domain in NewIAMSMTPConfigWriteModel * fix: add code needed by SetUpInstance * fix: go tests and warn about passing context to InstanceAggregateFromWriteModel * fix: i18n and add missing trans for fr, it, zh * fix: add e2e tests * docs: add smtp templates * fix: remove provider_type, add description * fix: remaining error from merge main * fix: add @stebenz change for primary key * fix: inactive placed after removed to prevent deleted configs to show as inactive * fix: smtp provider id can be empty (migrated) * feat: add mailchimp transactional template * feat: add Brevo (Sendinblue) template * feat: change brevo logo, add color to tls icon * fix: queries use resourceowner, id must not be empty * fix: deal with old smtp settings and tests * fix: resourceOwner is the instanceID * fix: remove aggregate_id, rename SMTPConfigByAggregateID with SMTPConfigActive * fix: add tests for multiple configs with different IDs * fix: conflict * fix: remove notification-smtp-provider * fix: add @peintnermax suggestions, rename module and fix e2e tests * fix: remove material legacy modules * fix: remove ctx as parameter for InstanceAggregateFromWriteModel * fix: add Id to SMTPConfigToPb * fix: change InstanceAggregateFromWriteModel to avoid linter errors * fix import * rm unused package-lock * update yarn lock --------- Co-authored-by: Elio Bischof <elio@zitadel.com> Co-authored-by: Max Peintner <max@caos.ch> Co-authored-by: Stefan Benz <46600784+stebenz@users.noreply.github.com>
93 lines
2.5 KiB
Go
93 lines
2.5 KiB
Go
package command
|
|
|
|
import (
|
|
"golang.org/x/text/language"
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
"github.com/zitadel/zitadel/internal/repository/instance"
|
|
)
|
|
|
|
type InstanceWriteModel struct {
|
|
eventstore.WriteModel
|
|
|
|
Name string
|
|
State domain.InstanceState
|
|
GeneratedDomain string
|
|
Domains []string
|
|
|
|
DefaultOrgID string
|
|
ProjectID string
|
|
DefaultLanguage language.Tag
|
|
}
|
|
|
|
func NewInstanceWriteModel(instanceID string) *InstanceWriteModel {
|
|
return &InstanceWriteModel{
|
|
WriteModel: eventstore.WriteModel{
|
|
InstanceID: instanceID,
|
|
AggregateID: instanceID,
|
|
ResourceOwner: instanceID,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (wm *InstanceWriteModel) Reduce() error {
|
|
for _, event := range wm.Events {
|
|
switch e := event.(type) {
|
|
case *instance.InstanceAddedEvent:
|
|
wm.Name = e.Name
|
|
wm.State = domain.InstanceStateActive
|
|
case *instance.InstanceChangedEvent:
|
|
wm.Name = e.Name
|
|
case *instance.InstanceRemovedEvent:
|
|
wm.State = domain.InstanceStateRemoved
|
|
case *instance.DomainAddedEvent:
|
|
if e.Generated {
|
|
wm.GeneratedDomain = e.Domain
|
|
}
|
|
wm.Domains = append(wm.Domains, e.Domain)
|
|
case *instance.DomainRemovedEvent:
|
|
for _, customDomain := range wm.Domains {
|
|
if customDomain == e.Domain {
|
|
wm.Domains = removeDomainFromDomains(wm.Domains, e.Domain)
|
|
}
|
|
}
|
|
case *instance.ProjectSetEvent:
|
|
wm.ProjectID = e.ProjectID
|
|
case *instance.DefaultOrgSetEvent:
|
|
wm.DefaultOrgID = e.OrgID
|
|
case *instance.DefaultLanguageSetEvent:
|
|
wm.DefaultLanguage = e.Language
|
|
}
|
|
}
|
|
return wm.WriteModel.Reduce()
|
|
}
|
|
|
|
func (wm *InstanceWriteModel) Query() *eventstore.SearchQueryBuilder {
|
|
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
|
|
ResourceOwner(wm.ResourceOwner).
|
|
AddQuery().
|
|
AggregateTypes(instance.AggregateType).
|
|
AggregateIDs(wm.AggregateID).
|
|
EventTypes(
|
|
instance.InstanceAddedEventType,
|
|
instance.InstanceChangedEventType,
|
|
instance.InstanceRemovedEventType,
|
|
instance.InstanceDomainAddedEventType,
|
|
instance.InstanceDomainRemovedEventType,
|
|
instance.ProjectSetEventType,
|
|
instance.DefaultOrgSetEventType,
|
|
instance.DefaultLanguageSetEventType).
|
|
Builder()
|
|
}
|
|
|
|
func InstanceAggregateFromWriteModel(wm *eventstore.WriteModel) *eventstore.Aggregate {
|
|
return &eventstore.Aggregate{
|
|
ID: wm.AggregateID,
|
|
Type: instance.AggregateType,
|
|
ResourceOwner: wm.ResourceOwner,
|
|
InstanceID: wm.InstanceID,
|
|
Version: instance.AggregateVersion,
|
|
}
|
|
}
|