using System;
using System.ComponentModel.DataAnnotations;
namespace Jellyfin.Data.Entities.Security
{
///
/// An entity representing a device.
///
public class Device
{
///
/// Initializes a new instance of the class.
///
/// The user id.
/// The app name.
/// The app version.
/// The device name.
/// The device id.
public Device(Guid userId, string appName, string appVersion, string deviceName, string deviceId)
{
UserId = userId;
AppName = appName;
AppVersion = appVersion;
DeviceName = deviceName;
DeviceId = deviceId;
DateCreated = DateTime.UtcNow;
DateLastActivity = DateCreated;
// Non-nullable for EF Core, as this is a required relationship.
User = null!;
}
public int Id { get; private set; }
///
/// Gets the user id.
///
public Guid UserId { get; private set; }
///
/// Gets or sets the app name.
///
[MaxLength(64)]
[StringLength(64)]
public string AppName { get; set; }
///
/// Gets or sets the app version.
///
[MaxLength(32)]
[StringLength(32)]
public string AppVersion { get; set; }
///
/// Gets or sets the device name.
///
[MaxLength(64)]
[StringLength(64)]
public string DeviceName { get; set; }
///
/// Gets or sets the device id.
///
[MaxLength(256)]
[StringLength(256)]
public string DeviceId { get; set; }
///
/// Gets or sets a value indicating whether this device is active.
///
public bool IsActive { get; set; }
///
/// Gets the date this device was created.
///
public DateTime DateCreated { get; private set; }
///
/// Gets or sets the date of last activity.
///
public DateTime DateLastActivity { get; set; }
///
/// Gets the user.
///
public User User { get; private set; }
}
}