mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
52 lines
944 B
Go
52 lines
944 B
Go
package member
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/caos/zitadel/internal/errors"
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
|
)
|
|
|
|
const (
|
|
RemovedEventType = "member.removed"
|
|
)
|
|
|
|
type RemovedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
UserID string `json:"userId"`
|
|
}
|
|
|
|
func (e *RemovedEvent) CheckPrevious() bool {
|
|
return true
|
|
}
|
|
|
|
func (e *RemovedEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func NewRemovedEvent(
|
|
base *eventstore.BaseEvent,
|
|
userID string,
|
|
) *RemovedEvent {
|
|
|
|
return &RemovedEvent{
|
|
BaseEvent: *base,
|
|
UserID: userID,
|
|
}
|
|
}
|
|
|
|
func RemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &RemovedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "POLIC-Ep4ip", "unable to unmarshal label policy")
|
|
}
|
|
|
|
return e, nil
|
|
}
|