2020-11-17 12:44:37 +00:00
|
|
|
package idp
|
|
|
|
|
2020-11-25 19:04:32 +00:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
2020-11-17 12:44:37 +00:00
|
|
|
|
2020-11-25 19:04:32 +00:00
|
|
|
"github.com/caos/zitadel/internal/errors"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
|
|
|
)
|
2020-11-17 12:44:37 +00:00
|
|
|
|
2020-11-25 19:04:32 +00:00
|
|
|
type ConfigDeactivatedEvent struct {
|
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
|
|
|
|
ConfigID string `idpConfigId`
|
2020-11-17 12:44:37 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 19:04:32 +00:00
|
|
|
func NewConfigDeactivatedEvent(
|
2020-11-17 12:44:37 +00:00
|
|
|
base *eventstore.BaseEvent,
|
|
|
|
configID string,
|
2020-11-25 19:04:32 +00:00
|
|
|
) *ConfigDeactivatedEvent {
|
2020-11-17 12:44:37 +00:00
|
|
|
|
2020-11-25 19:04:32 +00:00
|
|
|
return &ConfigDeactivatedEvent{
|
2020-11-17 12:44:37 +00:00
|
|
|
BaseEvent: *base,
|
2020-11-25 19:04:32 +00:00
|
|
|
ConfigID: configID,
|
2020-11-17 12:44:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:04:32 +00:00
|
|
|
func (e *ConfigDeactivatedEvent) CheckPrevious() bool {
|
2020-11-17 12:44:37 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:04:32 +00:00
|
|
|
func (e *ConfigDeactivatedEvent) Data() interface{} {
|
2020-11-17 12:44:37 +00:00
|
|
|
return e
|
|
|
|
}
|
2020-11-25 19:04:32 +00:00
|
|
|
|
2020-11-26 12:14:07 +00:00
|
|
|
func ConfigDeactivatedEventMapper(event *repository.Event) (*ConfigDeactivatedEvent, error) {
|
2020-11-25 19:04:32 +00:00
|
|
|
e := &ConfigDeactivatedEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
|
|
|
}
|
|
|
|
|
|
|
|
return e, nil
|
|
|
|
}
|