1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 15:42:48 -05:00

organize event models. stub out event services

This commit is contained in:
Kyle Spearrin
2017-12-01 09:22:04 -05:00
parent ba9cca057e
commit f4586002c4
14 changed files with 194 additions and 91 deletions

View File

@ -0,0 +1,29 @@
using Bit.Core.Enums;
using Bit.Core.Models.Table;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Data
{
public class CipherEvent : EventTableEntity
{
public CipherEvent(Cipher cipher, EventType type)
{
if(cipher.OrganizationId.HasValue)
{
PartitionKey = $"OrganizationId={cipher.OrganizationId.Value}";
}
else
{
PartitionKey = $"UserId={cipher.UserId.Value}";
}
RowKey = string.Format("Date={0}__CipherId={1}__Type={2}",
CoreHelpers.DateTimeToTableStorageKey(), cipher.Id, type);
OrganizationId = cipher.OrganizationId;
UserId = cipher.UserId;
CipherId = cipher.Id;
Type = type;
}
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using Bit.Core.Enums;
using Microsoft.WindowsAzure.Storage.Table;
namespace Bit.Core.Models.Data
{
public class EventTableEntity : TableEntity
{
public EventType Type { get; set; }
public Guid? UserId { get; set; }
public Guid? OrganizationId { get; set; }
public Guid? CipherId { get; set; }
public ICollection<Guid> CipherIds { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using System;
using Bit.Core.Enums;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Data
{
public class OrganizationEvent : EventTableEntity
{
public OrganizationEvent(Guid organizationId, EventType type)
{
PartitionKey = $"OrganizationId={organizationId}";
RowKey = string.Format("Date={0}__Type={1}",
CoreHelpers.DateTimeToTableStorageKey(), type);
OrganizationId = organizationId;
Type = type;
}
public OrganizationEvent(Guid organizationId, Guid userId, EventType type)
{
PartitionKey = $"OrganizationId={organizationId}";
RowKey = string.Format("Date={0}__UserId={1}__Type={2}",
CoreHelpers.DateTimeToTableStorageKey(), userId, type);
OrganizationId = organizationId;
UserId = userId;
Type = type;
}
}
}

View File

@ -0,0 +1,30 @@
using System;
using Bit.Core.Enums;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Data
{
public class UserEvent : EventTableEntity
{
public UserEvent(Guid userId, EventType type)
{
PartitionKey = $"UserId={userId}";
RowKey = string.Format("Date={0}__Type={1}",
CoreHelpers.DateTimeToTableStorageKey(), type);
UserId = userId;
Type = type;
}
public UserEvent(Guid userId, Guid organizationId, EventType type)
{
PartitionKey = $"OrganizationId={organizationId}";
RowKey = string.Format("Date={0}__UserId={1}__Type={2}",
CoreHelpers.DateTimeToTableStorageKey(), userId, type);
OrganizationId = organizationId;
UserId = userId;
Type = type;
}
}
}