Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Refactor SpamOK webapi model to eliminate duplicated code (#58)

Leendert de Borstce61fc36e1b2
diff --git a/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/AttachmentApiModel.cs b/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/AttachmentApiModel.cs
index 6200df3cc..5b2b0a941 100644
--- a/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/AttachmentApiModel.cs
+++ b/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/AttachmentApiModel.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace BlazorServer.Models.Spamok;
+namespace AliasVault.WebApp.Pages.Logins.Mailbox.Models.Spamok;
/// <summary>
/// Represents an attachment for an email.
diff --git a/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/Base/EmailApiModelBase.cs b/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/Base/EmailApiModelBase.cs
new file mode 100644
index 000000000..22ca2fb27
--- /dev/null
+++ b/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/Base/EmailApiModelBase.cs
@@ -0,0 +1,64 @@
+//-----------------------------------------------------------------------
+// <copyright file="EmailApiModelBase.cs" company="lanedirt">
+// Copyright (c) lanedirt. All rights reserved.
+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.WebApp.Pages.Logins.Mailbox.Models.Spamok;
+
+/// <summary>
+/// Represents a mailbox email API model base.
+/// </summary>
+public abstract class EmailApiModelBase
+{
+ /// <summary>
+ /// Gets or sets the ID of the email.
+ /// </summary>
+ public int Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the subject of the email.
+ /// </summary>
+ public string Subject { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the display name of the sender.
+ /// </summary>
+ public string FromDisplay { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the domain of the sender's email address.
+ /// </summary>
+ public string FromDomain { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the local part of the sender's email address.
+ /// </summary>
+ public string FromLocal { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the domain of the recipient's email address.
+ /// </summary>
+ public string ToDomain { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the local part of the recipient's email address.
+ /// </summary>
+ public string ToLocal { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the date of the email.
+ /// </summary>
+ public DateTime Date { get; set; }
+
+ /// <summary>
+ /// Gets or sets the system date of the email.
+ /// </summary>
+ public DateTime DateSystem { get; set; }
+
+ /// <summary>
+ /// Gets or sets the number of seconds ago the email was received.
+ /// </summary>
+ public double SecondsAgo { get; set; }
+}
diff --git a/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/EmailApiModel.cs b/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/EmailApiModel.cs
index c69564df1..70ca55280 100644
--- a/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/EmailApiModel.cs
+++ b/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/EmailApiModel.cs
@@ -5,63 +5,13 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace BlazorServer.Models.Spamok;
+namespace AliasVault.WebApp.Pages.Logins.Mailbox.Models.Spamok;
/// <summary>
/// Represents an email API model.
/// </summary>
-public class EmailApiModel
+public class EmailApiModel : EmailApiModelBase
{
- /// <summary>
- /// Gets or sets the ID of the email.
- /// </summary>
- public int Id { get; set; }
-
- /// <summary>
- /// Gets or sets the subject of the email.
- /// </summary>
- public string Subject { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the display name of the sender.
- /// </summary>
- public string FromDisplay { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the domain of the sender's email address.
- /// </summary>
- public string FromDomain { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the local part of the sender's email address.
- /// </summary>
- public string FromLocal { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the domain of the recipient's email address.
- /// </summary>
- public string ToDomain { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the local part of the recipient's email address.
- /// </summary>
- public string ToLocal { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the date of the email.
- /// </summary>
- public DateTime Date { get; set; }
-
- /// <summary>
- /// Gets or sets the system date of the email.
- /// </summary>
- public DateTime DateSystem { get; set; }
-
- /// <summary>
- /// Gets or sets the number of seconds ago the email was received.
- /// </summary>
- public double SecondsAgo { get; set; }
-
/// <summary>
/// Gets or sets the HTML content of the email message.
/// </summary>
diff --git a/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/MailboxEmailApiModel.cs b/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/MailboxEmailApiModel.cs
index e25c97d6b..fa78fdb54 100644
--- a/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/MailboxEmailApiModel.cs
+++ b/src/AliasVault.WebApp/Pages/Logins/Mailbox/Models/Spamok/MailboxEmailApiModel.cs
@@ -10,60 +10,10 @@ namespace AliasVault.WebApp.Pages.Logins.Mailbox.Models.Spamok;
/// <summary>
/// Represents a mailbox email API model.
/// </summary>
-public class MailboxEmailApiModel
+public class MailboxEmailApiModel : EmailApiModelBase
{
- /// <summary>
- /// Gets or sets the ID of the email.
- /// </summary>
- public int Id { get; set; }
-
- /// <summary>
- /// Gets or sets the subject of the email.
- /// </summary>
- public string Subject { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the display name of the sender.
- /// </summary>
- public string FromDisplay { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the domain of the sender's email address.
- /// </summary>
- public string FromDomain { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the local part of the sender's email address.
- /// </summary>
- public string FromLocal { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the domain of the recipient's email address.
- /// </summary>
- public string ToDomain { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the local part of the recipient's email address.
- /// </summary>
- public string ToLocal { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the date of the email.
- /// </summary>
- public DateTime Date { get; set; }
-
- /// <summary>
- /// Gets or sets the system date of the email.
- /// </summary>
- public DateTime DateSystem { get; set; }
-
/// <summary>
/// Gets or sets the preview of the email message.
/// </summary>
public string MessagePreview { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the number of seconds ago the email was received.
- /// </summary>
- public double SecondsAgo { get; set; }
}