1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-06 10:32:49 -05:00

cipher events

This commit is contained in:
Kyle Spearrin
2017-12-01 14:06:16 -05:00
parent 0662fc2163
commit a8fefb54c4
11 changed files with 86 additions and 36 deletions

View File

@ -7,25 +7,28 @@ namespace Bit.Core.Models.Data
{
public class CipherEvent : EventTableEntity
{
public CipherEvent(Cipher cipher, EventType type)
public CipherEvent(Cipher cipher, EventType type, Guid? actingUserId = null)
{
OrganizationId = cipher.OrganizationId;
UserId = cipher.UserId;
CipherId = cipher.Id;
Type = (int)type;
ActingUserId = actingUserId;
Timestamp = DateTime.UtcNow;
if(OrganizationId.HasValue)
{
UserId = null;
PartitionKey = $"OrganizationId={OrganizationId}";
RowKey = string.Format("Date={0}__CipherId={1}__ActingUserId={2}__Type={3}",
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), CipherId, ActingUserId, Type);
}
else
{
PartitionKey = $"UserId={UserId}";
RowKey = string.Format("Date={0}__CipherId={1}__Type={2}",
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), CipherId, Type);
}
RowKey = string.Format("Date={0}__CipherId={1}__Type={2}",
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), CipherId, Type);
}
}
}

View File

@ -11,5 +11,6 @@ namespace Bit.Core.Models.Data
public Guid? OrganizationId { get; set; }
public Guid? CipherId { get; set; }
public ICollection<Guid> CipherIds { get; set; }
public Guid? ActingUserId { get; set; }
}
}