fix: clean up writemodels user v3

This commit is contained in:
Stefan Benz 2024-09-26 09:25:31 +02:00
parent 4efe7d1786
commit f7b6dafe81
No known key found for this signature in database
GPG Key ID: 071AA751ED4F9D31
2 changed files with 22 additions and 22 deletions

View File

@ -8,8 +8,8 @@ func init() {
eventstore.RegisterFilterEventMapper(AggregateType, PasswordCreatedType, eventstore.GenericEventMapper[PasswordCreatedEvent]) eventstore.RegisterFilterEventMapper(AggregateType, PasswordCreatedType, eventstore.GenericEventMapper[PasswordCreatedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, PasswordCodeAddedType, eventstore.GenericEventMapper[PasswordCodeAddedEvent]) eventstore.RegisterFilterEventMapper(AggregateType, PasswordCodeAddedType, eventstore.GenericEventMapper[PasswordCodeAddedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, PasswordDeletedType, eventstore.GenericEventMapper[PasswordDeletedEvent]) eventstore.RegisterFilterEventMapper(AggregateType, PasswordDeletedType, eventstore.GenericEventMapper[PasswordDeletedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, JWTCreatedType, eventstore.GenericEventMapper[JWTCreatedEvent]) eventstore.RegisterFilterEventMapper(AggregateType, PublicKeyCreatedType, eventstore.GenericEventMapper[PublicKeyCreatedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, JWTDeletedType, eventstore.GenericEventMapper[JWTDeletedEvent]) eventstore.RegisterFilterEventMapper(AggregateType, PublicKeyDeletedType, eventstore.GenericEventMapper[PublicKeyDeletedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, PATCreatedType, eventstore.GenericEventMapper[PATCreatedEvent]) eventstore.RegisterFilterEventMapper(AggregateType, PATCreatedType, eventstore.GenericEventMapper[PATCreatedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, PATDeletedType, eventstore.GenericEventMapper[PATDeletedEvent]) eventstore.RegisterFilterEventMapper(AggregateType, PATDeletedType, eventstore.GenericEventMapper[PATDeletedEvent])
} }

View File

@ -9,12 +9,12 @@ import (
) )
const ( const (
jwtPrefix = eventPrefix + "jwt." publicKeyPrefix = eventPrefix + "pk."
JWTCreatedType = jwtPrefix + "created" PublicKeyCreatedType = publicKeyPrefix + "created"
JWTDeletedType = jwtPrefix + "deleted" PublicKeyDeletedType = publicKeyPrefix + "deleted"
) )
type JWTCreatedEvent struct { type PublicKeyCreatedEvent struct {
*eventstore.BaseEvent `json:"-"` *eventstore.BaseEvent `json:"-"`
UserID string `json:"userID"` UserID string `json:"userID"`
@ -24,34 +24,34 @@ type JWTCreatedEvent struct {
TriggeredAtOrigin string `json:"triggerOrigin,omitempty"` TriggeredAtOrigin string `json:"triggerOrigin,omitempty"`
} }
func (e *JWTCreatedEvent) SetBaseEvent(event *eventstore.BaseEvent) { func (e *PublicKeyCreatedEvent) SetBaseEvent(event *eventstore.BaseEvent) {
e.BaseEvent = event e.BaseEvent = event
} }
func (e *JWTCreatedEvent) Payload() interface{} { func (e *PublicKeyCreatedEvent) Payload() interface{} {
return e return e
} }
func (e *JWTCreatedEvent) UniqueConstraints() []*eventstore.UniqueConstraint { func (e *PublicKeyCreatedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
return nil return nil
} }
func (e *JWTCreatedEvent) TriggerOrigin() string { func (e *PublicKeyCreatedEvent) TriggerOrigin() string {
return e.TriggeredAtOrigin return e.TriggeredAtOrigin
} }
func NewJWTCreatedEvent( func NewPublicKeyCreatedEvent(
ctx context.Context, ctx context.Context,
aggregate *eventstore.Aggregate, aggregate *eventstore.Aggregate,
userID string, userID string,
expirationDate time.Time, expirationDate time.Time,
publicKey []byte, publicKey []byte,
) *JWTCreatedEvent { ) *PublicKeyCreatedEvent {
return &JWTCreatedEvent{ return &PublicKeyCreatedEvent{
BaseEvent: eventstore.NewBaseEventForPush( BaseEvent: eventstore.NewBaseEventForPush(
ctx, ctx,
aggregate, aggregate,
JWTCreatedType, PublicKeyCreatedType,
), ),
UserID: userID, UserID: userID,
ExpirationDate: expirationDate, ExpirationDate: expirationDate,
@ -60,31 +60,31 @@ func NewJWTCreatedEvent(
} }
} }
type JWTDeletedEvent struct { type PublicKeyDeletedEvent struct {
*eventstore.BaseEvent `json:"-"` *eventstore.BaseEvent `json:"-"`
} }
func (e *JWTDeletedEvent) SetBaseEvent(event *eventstore.BaseEvent) { func (e *PublicKeyDeletedEvent) SetBaseEvent(event *eventstore.BaseEvent) {
e.BaseEvent = event e.BaseEvent = event
} }
func (e *JWTDeletedEvent) Payload() interface{} { func (e *PublicKeyDeletedEvent) Payload() interface{} {
return e return e
} }
func (e *JWTDeletedEvent) UniqueConstraints() []*eventstore.UniqueConstraint { func (e *PublicKeyDeletedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
return nil return nil
} }
func NewJWTDeletedEvent( func NewPublicKeyDeletedEvent(
ctx context.Context, ctx context.Context,
aggregate *eventstore.Aggregate, aggregate *eventstore.Aggregate,
) *JWTDeletedEvent { ) *PublicKeyDeletedEvent {
return &JWTDeletedEvent{ return &PublicKeyDeletedEvent{
BaseEvent: eventstore.NewBaseEventForPush( BaseEvent: eventstore.NewBaseEventForPush(
ctx, ctx,
aggregate, aggregate,
JWTDeletedType, PublicKeyDeletedType,
), ),
} }
} }