mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00
record installation devices
This commit is contained in:
@ -8,6 +8,7 @@ namespace Bit.Core.Models.Api
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string DeviceId { get; set; }
|
||||
public string Identifier { get; set; }
|
||||
[Required]
|
||||
public PushType? Type { get; set; }
|
||||
|
36
src/Core/Models/Data/InstallationDeviceEntity.cs
Normal file
36
src/Core/Models/Data/InstallationDeviceEntity.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using Microsoft.WindowsAzure.Storage.Table;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
public class InstallationDeviceEntity : TableEntity
|
||||
{
|
||||
public InstallationDeviceEntity() { }
|
||||
|
||||
public InstallationDeviceEntity(Guid installationId, Guid deviceId)
|
||||
{
|
||||
PartitionKey = installationId.ToString();
|
||||
RowKey = deviceId.ToString();
|
||||
}
|
||||
|
||||
public InstallationDeviceEntity(string prefixedDeviceId)
|
||||
{
|
||||
var parts = prefixedDeviceId.Split("_");
|
||||
if(parts.Length < 2)
|
||||
{
|
||||
throw new ArgumentException("Not enough parts.");
|
||||
}
|
||||
if(!Guid.TryParse(parts[0], out var installationId) || !Guid.TryParse(parts[1], out var deviceId))
|
||||
{
|
||||
throw new ArgumentException("Could not parse parts.");
|
||||
}
|
||||
PartitionKey = parts[0];
|
||||
RowKey = parts[1];
|
||||
}
|
||||
|
||||
public static bool IsInstallationDeviceId(string deviceId)
|
||||
{
|
||||
return deviceId != null && deviceId.Length == 73 && deviceId[36] == '_';
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user