mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 20:38:00 +00:00
f680dd934d
* chore: rename package errors to zerrors * rename package errors to gerrors * fix error related linting issues * fix zitadel error assertion * fix gosimple linting issues * fix deprecated linting issues * resolve gci linting issues * fix import structure --------- Co-authored-by: Elio Bischof <elio@zitadel.com>
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package instance
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
|
)
|
|
|
|
const (
|
|
DefaultOrgSetEventType eventstore.EventType = "instance.default.org.set"
|
|
)
|
|
|
|
type DefaultOrgSetEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
OrgID string `json:"orgId"`
|
|
}
|
|
|
|
func (e *DefaultOrgSetEvent) Payload() interface{} {
|
|
return e
|
|
}
|
|
|
|
func (e *DefaultOrgSetEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func NewDefaultOrgSetEventEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
orgID string,
|
|
) *DefaultOrgSetEvent {
|
|
return &DefaultOrgSetEvent{
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
DefaultOrgSetEventType,
|
|
),
|
|
OrgID: orgID,
|
|
}
|
|
}
|
|
|
|
func DefaultOrgSetMapper(event eventstore.Event) (eventstore.Event, error) {
|
|
e := &DefaultOrgSetEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
err := event.Unmarshal(e)
|
|
if err != nil {
|
|
return nil, zerrors.ThrowInternal(err, "IAM-cdFZH", "unable to unmarshal default org set")
|
|
}
|
|
|
|
return e, nil
|
|
}
|