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, PasswordCodeAddedType, eventstore.GenericEventMapper[PasswordCodeAddedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, PasswordDeletedType, eventstore.GenericEventMapper[PasswordDeletedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, JWTCreatedType, eventstore.GenericEventMapper[JWTCreatedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, JWTDeletedType, eventstore.GenericEventMapper[JWTDeletedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, PublicKeyCreatedType, eventstore.GenericEventMapper[PublicKeyCreatedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, PublicKeyDeletedType, eventstore.GenericEventMapper[PublicKeyDeletedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, PATCreatedType, eventstore.GenericEventMapper[PATCreatedEvent])
eventstore.RegisterFilterEventMapper(AggregateType, PATDeletedType, eventstore.GenericEventMapper[PATDeletedEvent])
}

View File

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