fix(eventstore): set owner of previous events if present

This commit is contained in:
adlerhurst 2024-12-18 09:55:43 +01:00
parent b9e351ab84
commit a6f86f1203

View File

@ -124,7 +124,18 @@ func scanToSequence(rows *sql.Rows, sequences []*latestSequence) error {
return nil return nil
} }
sequence.sequence = currentSequence sequence.sequence = currentSequence
if sequence.aggregate.ResourceOwner == "" { if resourceOwner != "" && sequence.aggregate.ResourceOwner != "" && sequence.aggregate.ResourceOwner != resourceOwner {
logging.WithFields(
"current_sequence", sequence.sequence,
"instance_id", sequence.aggregate.InstanceID,
"agg_type", sequence.aggregate.Type,
"agg_id", sequence.aggregate.ID,
"current_owner", resourceOwner,
"provided_owner", sequence.aggregate.ResourceOwner,
).Info("would have set wrong resource owner")
}
// set resource owner from previous events
if resourceOwner != "" {
sequence.aggregate.ResourceOwner = resourceOwner sequence.aggregate.ResourceOwner = resourceOwner
} }