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:
@ -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;
|
||||
|
23
src/Core/Models/Data/CollectionEvent.cs
Normal file
23
src/Core/Models/Data/CollectionEvent.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
23
src/Core/Models/Data/GroupEvent.cs
Normal file
23
src/Core/Models/Data/GroupEvent.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
24
src/Core/Models/Data/OrganizationUserEvent.cs
Normal file
24
src/Core/Models/Data/OrganizationUserEvent.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user