mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
make event message processing idempotent
This commit is contained in:
@ -65,7 +65,8 @@ namespace Bit.Core.Models.Data
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void ReadEntity(IDictionary<string, EntityProperty> properties, OperationContext operationContext)
|
||||
public override void ReadEntity(IDictionary<string, EntityProperty> properties,
|
||||
OperationContext operationContext)
|
||||
{
|
||||
base.ReadEntity(properties, operationContext);
|
||||
|
||||
@ -82,9 +83,9 @@ namespace Bit.Core.Models.Data
|
||||
}
|
||||
}
|
||||
|
||||
public static List<EventTableEntity> IndexEvent(IEvent e)
|
||||
public static List<EventTableEntity> IndexEvent(EventMessage e)
|
||||
{
|
||||
var uniquifier = Guid.NewGuid();
|
||||
var uniquifier = e.IdempotencyId.GetValueOrDefault(Guid.NewGuid());
|
||||
var pKey = e.OrganizationId.HasValue ? $"OrganizationId={e.OrganizationId}" : $"UserId={e.UserId}";
|
||||
var dateKey = CoreHelpers.DateTimeToTableStorageKey(e.Date);
|
||||
|
||||
@ -102,7 +103,8 @@ namespace Bit.Core.Models.Data
|
||||
entities.Add(new EventTableEntity(e)
|
||||
{
|
||||
PartitionKey = pKey,
|
||||
RowKey = string.Format("ActingUserId={0}__Date={1}__Uniquifier={2}", e.ActingUserId, dateKey, uniquifier)
|
||||
RowKey = string.Format("ActingUserId={0}__Date={1}__Uniquifier={2}",
|
||||
e.ActingUserId, dateKey, uniquifier)
|
||||
});
|
||||
}
|
||||
|
||||
@ -111,7 +113,8 @@ namespace Bit.Core.Models.Data
|
||||
entities.Add(new EventTableEntity(e)
|
||||
{
|
||||
PartitionKey = pKey,
|
||||
RowKey = string.Format("CipherId={0}__Date={1}__Uniquifier={2}", e.CipherId, dateKey, uniquifier)
|
||||
RowKey = string.Format("CipherId={0}__Date={1}__Uniquifier={2}",
|
||||
e.CipherId, dateKey, uniquifier)
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user