zitadel/internal/repository/user/human_avatar.go
Florian Forster fa9f581d56
chore(v2): move to new org (#3499)
* chore: move to new org

* logging

* fix: org rename caos -> zitadel

Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
2022-04-26 23:01:45 +00:00

64 lines
1.6 KiB
Go

package user
import (
"context"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/repository"
"github.com/zitadel/zitadel/internal/repository/asset"
)
const (
avatarEventPrefix = humanEventPrefix + "avatar."
HumanAvatarAddedType = avatarEventPrefix + "added"
HumanAvatarRemovedType = avatarEventPrefix + "removed"
)
type HumanAvatarAddedEvent struct {
asset.AddedEvent
}
func NewHumanAvatarAddedEvent(ctx context.Context, aggregate *eventstore.Aggregate, storageKey string) *HumanAvatarAddedEvent {
return &HumanAvatarAddedEvent{
AddedEvent: *asset.NewAddedEvent(
eventstore.NewBaseEventForPush(
ctx,
aggregate,
HumanAvatarAddedType),
storageKey),
}
}
func HumanAvatarAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
e, err := asset.AddedEventMapper(event)
if err != nil {
return nil, err
}
return &HumanAvatarAddedEvent{AddedEvent: *e.(*asset.AddedEvent)}, nil
}
type HumanAvatarRemovedEvent struct {
asset.RemovedEvent
}
func NewHumanAvatarRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate, storageKey string) *HumanAvatarRemovedEvent {
return &HumanAvatarRemovedEvent{
RemovedEvent: *asset.NewRemovedEvent(
eventstore.NewBaseEventForPush(
ctx,
aggregate,
HumanAvatarRemovedType),
storageKey),
}
}
func HumanAvatarRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
e, err := asset.RemovedEventMapper(event)
if err != nil {
return nil, err
}
return &HumanAvatarRemovedEvent{RemovedEvent: *e.(*asset.RemovedEvent)}, nil
}