mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 12:57:34 +00:00
chore: move the go code into a subfolder
This commit is contained in:
57
apps/api/internal/v2/projection/org_primary_domain.go
Normal file
57
apps/api/internal/v2/projection/org_primary_domain.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package projection
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/v2/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/v2/org"
|
||||
)
|
||||
|
||||
type OrgPrimaryDomain struct {
|
||||
projection
|
||||
|
||||
id string
|
||||
|
||||
Domain string
|
||||
}
|
||||
|
||||
func NewOrgPrimaryDomain(id string) *OrgPrimaryDomain {
|
||||
return &OrgPrimaryDomain{
|
||||
id: id,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *OrgPrimaryDomain) Filter() []*eventstore.Filter {
|
||||
return []*eventstore.Filter{
|
||||
eventstore.NewFilter(
|
||||
eventstore.FilterPagination(
|
||||
eventstore.GlobalPositionGreater(&p.position),
|
||||
),
|
||||
eventstore.AppendAggregateFilter(
|
||||
org.AggregateType,
|
||||
eventstore.AggregateIDs(p.id),
|
||||
eventstore.AppendEvent(
|
||||
eventstore.SetEventTypes(org.DomainPrimarySetType),
|
||||
),
|
||||
),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func (p *OrgPrimaryDomain) Reduce(events ...*eventstore.StorageEvent) error {
|
||||
for _, event := range events {
|
||||
if !p.shouldReduce(event) {
|
||||
continue
|
||||
}
|
||||
if event.Type != org.DomainPrimarySetType {
|
||||
continue
|
||||
}
|
||||
e, err := org.DomainPrimarySetEventFromStorage(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
p.Domain = e.Payload.Name
|
||||
p.projection.reduce(event)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user