//-----------------------------------------------------------------------
//
// Copyright (c) aliasvault. All rights reserved.
// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
//
//-----------------------------------------------------------------------
namespace AliasServerDb;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
///
/// Represents an email message.
///
[Index(nameof(ToLocal))]
[Index(nameof(Date))]
[Index(nameof(DateSystem))]
[Index(nameof(Visible))]
[Index(nameof(PushNotificationSent))]
public class Email
{
///
/// Gets or sets the ID of the email.
///
public int Id { get; set; }
///
/// Gets or sets encryption key foreign key.
///
[StringLength(255)]
public Guid UserEncryptionKeyId { get; set; }
///
/// Gets or sets foreign key to the UserEncryptionKey object which contains the public key used for encrypting
/// the symmetric encryption key.
///
[ForeignKey("UserEncryptionKeyId")]
public virtual UserEncryptionKey EncryptionKey { get; set; } = null!;
///
/// Gets or sets the encrypted symmetric key which was used to encrypt the email message.
/// This key is encrypted with the public key of the user.
///
public string EncryptedSymmetricKey { get; set; } = null!;
///
/// Gets or sets the subject of the email.
///
public string Subject { get; set; } = null!;
///
/// Gets or sets the sender's email address.
///
public string From { get; set; } = null!;
///
/// Gets or sets the local part of the sender's email address.
///
public string FromLocal { get; set; } = null!;
///
/// Gets or sets the domain part of the sender's email address.
///
public string FromDomain { get; set; } = null!;
///
/// Gets or sets the recipient's email address.
///
public string To { get; set; } = null!;
///
/// Gets or sets the local part of the recipient's email address.
///
public string ToLocal { get; set; } = null!;
///
/// Gets or sets the domain part of the recipient's email address.
///
public string ToDomain { get; set; } = null!;
///
/// Gets or sets the date and time when the email was sent.
///
public DateTime Date { get; set; }
///
/// Gets or sets the system date and time when the email was received.
///
public DateTime DateSystem { get; set; }
///
/// Gets or sets the HTML content of the email message.
///
public string? MessageHtml { get; set; }
///
/// Gets or sets the plain text content of the email message.
///
public string? MessagePlain { get; set; }
///
/// Gets or sets the preview of the email message.
///
public string? MessagePreview { get; set; }
///
/// Gets or sets the source of the email message.
///
public string MessageSource { get; set; } = null!;
///
/// Gets or sets a value indicating whether the email is visible.
///
public bool Visible { get; set; }
///
/// Gets or sets a value indicating whether a push notification has been sent for the email.
///
public bool PushNotificationSent { get; set; }
///
/// Gets or sets the collection of email attachments.
///
public virtual List Attachments { get; set; } = [];
}