zitadel/internal/repository/instance/event_org_set.go
Tim Möhlmann f680dd934d
refactor: rename package errors to zerrors (#7039)
* 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>
2023-12-08 15:30:55 +01:00

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
}