mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
65a8efeb0e
* fix: use pointer in events * fix: change user requests to command side * fix: org policy * fix: profile
36 lines
811 B
Go
36 lines
811 B
Go
package command
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
"github.com/caos/zitadel/internal/v2/repository/policy"
|
|
)
|
|
|
|
type LabelPolicyWriteModel struct {
|
|
eventstore.WriteModel
|
|
|
|
PrimaryColor string
|
|
SecondaryColor string
|
|
IsActive bool
|
|
}
|
|
|
|
func (wm *LabelPolicyWriteModel) Reduce() error {
|
|
for _, event := range wm.Events {
|
|
switch e := event.(type) {
|
|
case *policy.LabelPolicyAddedEvent:
|
|
wm.PrimaryColor = e.PrimaryColor
|
|
wm.SecondaryColor = e.SecondaryColor
|
|
wm.IsActive = true
|
|
case *policy.LabelPolicyChangedEvent:
|
|
if e.PrimaryColor != nil {
|
|
wm.PrimaryColor = *e.PrimaryColor
|
|
}
|
|
if e.SecondaryColor != nil {
|
|
wm.SecondaryColor = *e.SecondaryColor
|
|
}
|
|
case *policy.LabelPolicyRemovedEvent:
|
|
wm.IsActive = false
|
|
}
|
|
}
|
|
return wm.WriteModel.Reduce()
|
|
}
|