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

events for collections, groups, and org users

This commit is contained in:
Kyle Spearrin
2017-12-01 16:00:30 -05:00
parent a8fefb54c4
commit 28770d3761
20 changed files with 182 additions and 27 deletions

View File

@ -7,7 +7,7 @@ namespace Bit.Core.Models.Data
{
public class CipherEvent : EventTableEntity
{
public CipherEvent(Cipher cipher, EventType type, Guid? actingUserId = null)
public CipherEvent(Cipher cipher, Guid? actingUserId, EventType type)
{
OrganizationId = cipher.OrganizationId;
UserId = cipher.UserId;

View File

@ -0,0 +1,23 @@
using System;
using Bit.Core.Enums;
using Bit.Core.Models.Table;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Data
{
public class CollectionEvent : EventTableEntity
{
public CollectionEvent(Collection collection, Guid actingUserId, EventType type)
{
OrganizationId = collection.OrganizationId;
CollectionId = collection.Id;
Type = (int)type;
ActingUserId = actingUserId;
Timestamp = DateTime.UtcNow;
PartitionKey = $"OrganizationId={OrganizationId}";
RowKey = string.Format("Date={0}__ActingUserId={1}__Type={2}",
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), ActingUserId, Type);
}
}
}

View File

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

View File

@ -0,0 +1,23 @@
using System;
using Bit.Core.Enums;
using Bit.Core.Models.Table;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Data
{
public class GroupEvent : EventTableEntity
{
public GroupEvent(Group group, Guid actingUserId, EventType type)
{
OrganizationId = group.OrganizationId;
GroupId = group.Id;
Type = (int)type;
ActingUserId = actingUserId;
Timestamp = DateTime.UtcNow;
PartitionKey = $"OrganizationId={OrganizationId}";
RowKey = string.Format("Date={0}__ActingUserId={1}__Type={2}",
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), ActingUserId, Type);
}
}
}

View File

@ -1,32 +1,22 @@
using System;
using Bit.Core.Enums;
using Bit.Core.Models.Table;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Data
{
public class OrganizationEvent : EventTableEntity
{
public OrganizationEvent(Guid organizationId, EventType type)
public OrganizationEvent(Organization organization, Guid actingUserId, EventType type)
{
OrganizationId = organizationId;
OrganizationId = organization.Id;
Type = (int)type;
ActingUserId = actingUserId;
Timestamp = DateTime.UtcNow;
PartitionKey = $"OrganizationId={OrganizationId}";
RowKey = string.Format("Date={0}__Type={1}",
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), Type);
}
public OrganizationEvent(Guid organizationId, Guid userId, EventType type)
{
OrganizationId = organizationId;
UserId = userId;
Type = (int)type;
Timestamp = DateTime.UtcNow;
PartitionKey = $"OrganizationId={OrganizationId}";
RowKey = string.Format("Date={0}__UserId={1}__Type={2}",
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), UserId, Type);
RowKey = string.Format("Date={0}__ActingUserId={1}__Type={2}",
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), ActingUserId, Type);
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using Bit.Core.Enums;
using Bit.Core.Models.Table;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Data
{
public class OrganizationUserEvent : EventTableEntity
{
public OrganizationUserEvent(OrganizationUser organizationUser, Guid actingUserId, EventType type)
{
OrganizationId = organizationUser.OrganizationId;
UserId = organizationUser.UserId;
OrganizationUserId = organizationUser.Id;
Type = (int)type;
ActingUserId = actingUserId;
Timestamp = DateTime.UtcNow;
PartitionKey = $"OrganizationId={OrganizationId}";
RowKey = string.Format("Date={0}__ActingUserId={1}__Type={2}",
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), ActingUserId, Type);
}
}
}