#nullable enable using System.ComponentModel.DataAnnotations; using Bit.Core.Entities; using Bit.Core.Tools.Enums; using Bit.Core.Utilities; namespace Bit.Core.Tools.Entities; /// /// An end-to-end encrypted secret accessible to arbitrary /// entities through a fixed URI. /// public class Send : ITableObject { /// /// Uniquely identifies this send. /// public Guid Id { get; set; } /// /// Identifies the user that created this send. /// public Guid? UserId { get; set; } /// /// Identifies the organization that created this send. /// /// /// Not presently in-use by client applications. /// public Guid? OrganizationId { get; set; } /// /// Describes the data being sent. This field determines how /// the field is interpreted. /// public SendType Type { get; set; } /// /// Stores data containing or pointing to the transmitted secret. JSON. /// /// /// Must be nullable due to several database column configuration. /// The application and all other databases assume this is not nullable. /// Tech debt ticket: PM-4128 /// public string? Data { get; set; } /// /// Stores the data's encryption key. Encrypted. /// /// /// Must be nullable due to MySql database column configuration. /// The application and all other databases assume this is not nullable. /// Tech debt ticket: PM-4128 /// public string? Key { get; set; } /// /// Password provided by the user. Protected with pbkdf2. /// [MaxLength(300)] public string? Password { get; set; } /// /// The send becomes unavailable to API callers when /// >= . /// public int? MaxAccessCount { get; set; } /// /// Number of times the content was accessed. /// /// /// This value is owned by the server. Clients cannot alter it. /// public int AccessCount { get; set; } /// /// The date this send was created. /// public DateTime CreationDate { get; internal set; } = DateTime.UtcNow; /// /// The date this send was last modified. /// public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow; /// /// The date this send becomes unavailable to API callers. /// public DateTime? ExpirationDate { get; set; } /// /// The date this send will be unconditionally deleted. /// /// /// This is set by server-side when the user doesn't specify a deletion date. /// public DateTime DeletionDate { get; set; } /// /// When this is true the send is not available to API callers, /// unless they're the creator. /// public bool Disabled { get; set; } /// /// Whether the creator's email address should be shown to the recipient. /// /// /// indicates the email may be shown. /// indicates the email should be hidden. /// indicates the client doesn't set the field and /// the email should be hidden. /// public bool? HideEmail { get; set; } /// /// Identifies the Cipher associated with this send. /// public Guid? CipherId { get; set; } /// /// Generates the send's /// public void SetNewId() { Id = CoreHelpers.GenerateComb(); } }