Skip to content

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

#196 Add email bulk delete option with checkboxes on email list page (#1526)

Danilo Guimarãesf3c203256e5f
diff --git a/apps/server/AliasVault.Admin/wwwroot/css/tailwind.css b/apps/server/AliasVault.Admin/wwwroot/css/tailwind.css
index 437c1a72c..4909b8589 100644
--- a/apps/server/AliasVault.Admin/wwwroot/css/tailwind.css
+++ b/apps/server/AliasVault.Admin/wwwroot/css/tailwind.css
@@ -1885,9 +1885,7 @@ video {
}
.transition {
- transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
- transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms;
}
diff --git a/apps/server/AliasVault.Api/Controllers/Email/EmailController.cs b/apps/server/AliasVault.Api/Controllers/Email/EmailController.cs
index 81543937f..6c05d0127 100644
--- a/apps/server/AliasVault.Api/Controllers/Email/EmailController.cs
+++ b/apps/server/AliasVault.Api/Controllers/Email/EmailController.cs
@@ -11,6 +11,7 @@ using AliasServerDb;
using AliasVault.Api.Controllers.Abstracts;
using AliasVault.Auth.IpAddress;
using AliasVault.Shared.Models.Spamok;
+using AliasVault.Shared.Models.WebApi.Email;
using Asp.Versioning;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
@@ -36,7 +37,13 @@ public class EmailController(ILogger<VaultController> logger, IAliasServerDbCont
{
await using var context = await dbContextFactory.CreateDbContextAsync();
- var (email, errorResult) = await AuthenticateAndRetrieveEmailAsync(id, context);
+ var user = await GetCurrentUserAsync();
+ if (user is null)
+ {
+ return Unauthorized("Not authenticated.");
+ }
+
+ var (email, errorResult) = await RetrieveEmailAsync(id, user, context);
if (errorResult != null)
{
return errorResult;
@@ -86,7 +93,13 @@ public class EmailController(ILogger<VaultController> logger, IAliasServerDbCont
{
await using var context = await dbContextFactory.CreateDbContextAsync();
- var (email, errorResult) = await AuthenticateAndRetrieveEmailAsync(id, context);
+ var user = await GetCurrentUserAsync();
+ if (user is null)
+ {
+ return Unauthorized("Not authenticated.");
+ }
+
+ var (email, errorResult) = await RetrieveEmailAsync(id, user, context);
if (errorResult != null)
{
return errorResult;
@@ -119,7 +132,13 @@ public class EmailController(ILogger<VaultController> logger, IAliasServerDbCont
{
await using var context = await dbContextFactory.CreateDbContextAsync();
- var (email, errorResult) = await AuthenticateAndRetrieveEmailAsync(id, context);
+ var user = await GetCurrentUserAsync();
+ if (user is null)
+ {
+ return Unauthorized("Not authenticated.");
+ }
+
+ var (email, errorResult) = await RetrieveEmailAsync(id, user, context);
if (errorResult != null)
{
return errorResult;
@@ -140,22 +159,67 @@ public class EmailController(ILogger<VaultController> logger, IAliasServerDbCont
}
/// <summary>
- /// Authenticates the user and retrieves the requested email.
+ /// Delete multiple emails.
/// </summary>
- /// <param name="id">The email ID to retrieve.</param>
- /// <param name="context">The database context.</param>
- /// <returns>A tuple containing the authenticated user, the email, and an IActionResult if there's an error.</returns>
- private async Task<(Email? Email, IActionResult? ErrorResult)> AuthenticateAndRetrieveEmailAsync(int id, AliasServerDbContext context)
+ /// <param name="model">Request model.</param>
+ /// <returns>A EmailBulkResponse instance representing the result of the asynchronous operation.</returns>
+ [HttpDelete(template: "bulk", Name = "BulkDelete")]
+ public async Task<IActionResult> BulkDelete([FromBody] EmailBulkRequest model)
{
+ await using var context = await dbContextFactory.CreateDbContextAsync();
+
var user = await GetCurrentUserAsync();
if (user is null)
{
- return (null, Unauthorized("Not authenticated."));
+ return Unauthorized("Not authenticated.");
}
- // Shadow-block: when active, emails received after the block took effect behave as if they do not exist.
- var shadowCutoff = await ipBlockListService.GetShadowBlockCutoffAsync(user, IpAddressUtility.GetRawIpAddressFromContext(HttpContext));
+ // Sanitize input
+ model.Ids = [.. model.Ids.Distinct().ToList().FindAll(id => id > 0)];
+
+ if (model.Ids.Count == 0)
+ {
+ // Nothing to delete
+ return StatusCode(304);
+ }
+
+ // For each email ID, validate if user has access and if email exists
+ foreach (int emailId in model.Ids)
+ {
+ var (email, errorResult) = await RetrieveEmailAsync(emailId, user, context);
+ if (errorResult != null)
+ {
+ return errorResult;
+ }
+ }
+
+ List<int> deletedEmails = [];
+ try
+ {
+ await context.Emails.Where(e => model.Ids.Contains(e.Id)).ExecuteDeleteAsync();
+ }
+ catch (Exception ex)
+ {
+ logger.LogError(ex, "An error occurred while deleting the emails.");
+ return StatusCode(500);
+ }
+ EmailBulkResponse returnValue = new()
+ {
+ SuccessfulEmailIds = model.Ids,
+ };
+ return Ok(returnValue);
+ }
+
+ /// <summary>
+ /// Retrieves the requested email.
+ /// </summary>
+ /// <param name="id">The email ID to retrieve.</param>
+ /// <param name="user">The authenticated Alis Vault user.</param>
+ /// <param name="context">The database context.</param>
+ /// <returns>A tuple containing the email, and an IActionResult if there's an error.</returns>
+ private async Task<(Email? Email, IActionResult? ErrorResult)> RetrieveEmailAsync(int id, AliasVaultUser user, AliasServerDbContext context)
+ {
// Retrieve email from database.
var email = await context.Emails
.Include(x => x.Attachments)
@@ -166,6 +230,9 @@ public class EmailController(ILogger<VaultController> logger, IAliasServerDbCont
return (null, NotFound("Email not found."));
}
+ // Shadow-block: when active, emails received after the block took effect behave as if they do not exist.
+ var shadowCutoff = await ipBlockListService.GetShadowBlockCutoffAsync(user, IpAddressUtility.GetRawIpAddressFromContext(HttpContext));
+
// Hide emails received after a shadow-block took effect.
if (shadowCutoff is not null && email.DateSystem > shadowCutoff.Value)
{
diff --git a/apps/server/AliasVault.Client/Main/Components/Email/EmailRow.razor b/apps/server/AliasVault.Client/Main/Components/Email/EmailRow.razor
index 0ca977c1f..aabc74fb5 100644
--- a/apps/server/AliasVault.Client/Main/Components/Email/EmailRow.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Email/EmailRow.razor
@@ -2,8 +2,18 @@
@using Microsoft.Extensions.Localization
@inject IStringLocalizerFactory LocalizerFactory
-<li class="@($"transition duration-150 ease-in-out cursor-pointer {(IsSelected ? "bg-primary-50 dark:bg-primary-900/30 border-l-4 border-primary-500 hover:bg-primary-200 dark:hover:bg-primary-900/50" : "hover:bg-gray-100 dark:hover:bg-gray-600")}")">
- <div @onclick="@(() => OnEmailClick.InvokeAsync(Email.Id))" class="p-4 flex justify-start items-start">
+<li class="@($"flex items-center transition duration-150 ease-in-out cursor-pointer {(IsSelected ? "bg-primary-50 dark:bg-primary-900/30 border-l-4 border-primary-500 hover:bg-primary-200 dark:hover:bg-primary-900/50" : "hover:bg-gray-100 dark:hover:bg-gray-600")}")">
+ <!-- Checkbox for multiple emails selection -->
+ <div class="pl-4 mr-2 flex-shrink-0" >
+ <input class="form-checkbox h-4 w-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"
+ type="checkbox"
+ value="@Email.IsChecked"
+ checked="@IsChecked"
+ @onclick="@(() => OnEmailCheck.InvokeAsync(Email.Id))" />
+ </div>
+ <!-- Email card -->
+ <div @onclick="@(() => OnEmailClick.InvokeAsync(Email.Id))" class="p-4 flex flex-grow min-w-0 justify-start items-start">
<div class="mr-4 flex-shrink-0">
<SenderInitials SenderName="@Email.FromName" SenderEmail="@Email.FromEmail" />
</div>
@@ -57,6 +67,18 @@
public EventCallback<int> OnEmailClick { get; set; }
+ /// <summary>
+ /// OnCheck handler for email.
+ /// </summary>
+ [Parameter]
+ public EventCallback<int> OnEmailCheck { get; set;}
+
+ /// <summary>
+ /// Whether this email is currently checked.
+ /// </summary>
+ [Parameter]
+ public bool IsChecked { get; set; }
+
/// <summary>
/// Whether this email is currently selected.
/// </summary>
@@ -70,6 +92,7 @@
public bool IsNewEmail { get; set; }
private MailListViewModel? _renderedEmail;
+ private bool _renderedIsChecked;
private bool _renderedIsSelected;
private bool _renderedIsNewEmail;
@@ -79,12 +102,13 @@
/// <returns>True when a re-render is required.</returns>
protected override bool ShouldRender()
{
- if (ReferenceEquals(_renderedEmail, Email) && _renderedIsSelected == IsSelected && _renderedIsNewEmail == IsNewEmail)
+ if (ReferenceEquals(_renderedEmail, Email) && _renderedIsChecked == IsChecked && _renderedIsSelected == IsSelected && _renderedIsNewEmail == IsNewEmail)
{
return false;
}
_renderedEmail = Email;
+ _renderedIsChecked = IsChecked;
_renderedIsSelected = IsSelected;
_renderedIsNewEmail = IsNewEmail;
return true;
diff --git a/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor b/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor
index 72f0665fb..2fbf28e23 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor
@@ -3,6 +3,7 @@
@using System.Text
@using System.Text.Json
@using AliasVault.Client.Main.Pages.Emails.Models
+@using AliasVault.RazorComponents.Services
@using AliasVault.Shared.Models.Spamok
@using AliasVault.Shared.Models.WebApi
@using AliasVault.Shared.Models.WebApi.Email
@@ -14,6 +15,7 @@
@inject ILogger<Home> Logger
@inject MinDurationLoadingService LoadingService
@inject ItemService ItemService
+@inject ConfirmModalService ConfirmModalService
@using Microsoft.Extensions.Localization
@implements IAsyncDisposable
@@ -34,6 +36,11 @@
<div class="w-3 h-3 mr-2 rounded-full bg-primary-300 border-2 border-primary-100 animate-pulse" title="@Localizer["AutoRefreshEnabledTooltip"]"></div>
}
<RefreshButton OnClick="HandleRefreshButtonClick" ButtonText="@Localizer["RefreshButton"]" />
+
+ @if (CheckedEmailIds.Count > 0)
+ {
+ <DeleteAllSelectedButton OnClick="ShowBulkDeleteConfirmation" ButtonText="@string.Format(Localizer["DeleteSelectedEmails"], CheckedEmailIds.Count)" />
+ }
</CustomActions>
</PageHeader>
@@ -104,6 +111,7 @@ else
<EmailRow
Email="email"
OnEmailClick="ShowAliasVaultEmailInModal"
+ IsChecked="@(CheckedEmailIds.Contains(email.Id))"
IsSelected="false"
IsNewEmail="@(NewEmailIds.Contains(email.Id))" />
}
@@ -134,7 +142,9 @@ else
{
<EmailRow
Email="email"
+ OnEmailCheck="CheckEmail"
OnEmailClick="SelectEmailForPreview"
+ IsChecked="@(CheckedEmailIds.Contains(email.Id))"
IsSelected="@(SelectedEmailId == email.Id)"
IsNewEmail="@(NewEmailIds.Contains(email.Id))" />
}
@@ -212,6 +222,7 @@ else
private CancellationTokenSource? _pollingCts;
private DotNetObjectReference<Home>? _dotNetRef;
private bool _isPageVisible = true;
+ private HashSet<int> CheckedEmailIds { get; set; } = new HashSet<int>();
private HashSet<int> NewEmailIds { get; set; } = new();
private HashSet<int> _knownEmailIds = new();
@@ -531,6 +542,7 @@ else
// Clear selected email when refreshing
SelectedEmailId = null;
SelectedEmail = null;
+ CheckedEmailIds.Clear();
// Reset pagination for fresh load (unless preserving current page for pagination)
if (!preserveCurrentPage)
@@ -660,6 +672,20 @@ else
await LoadSelectedEmailForPreview(emailId);
}
+ /// <summary>
+ /// Check an email for bulk actions (desktop layout).
+ /// </summary>
+ private void CheckEmail(int emailId)
+ {
+ if (CheckedEmailIds.Contains(emailId))
+ {
+ CheckedEmailIds.Remove(emailId);
+ } else
+ {
+ CheckedEmailIds.Add(emailId);
+ }
+ }
+
/// <summary>
/// Load the full email data for preview.
/// </summary>
@@ -719,20 +745,35 @@ else
/// Handle email deletion from preview panel.
/// </summary>
private async Task HandleEmailDeleted(int emailId)
+ {
+ await HandleEmailsDeleted(new List<int> {emailId});
+ }
+
+ /// <summary>
+ /// Handle emails deletion from preview panel.
+ /// </summary>
+ private async Task HandleEmailsDeleted(List<int> emailIds)
{
// Remove the deleted email from the list
- var deletedEmailIndex = EmailList.FindIndex(e => e.Id == emailId);
- EmailList.RemoveAll(e => e.Id == emailId);
+ var deletedSelectedEmailIndex = -1;
+
+ if (SelectedEmailId.HasValue && emailIds.Contains(SelectedEmailId.Value))
+ {
+ deletedSelectedEmailIndex = EmailList.FindIndex(e => e.Id == SelectedEmailId.Value);
+ }
+
+ EmailList.RemoveAll(e => emailIds.Contains(e.Id));
// Remove from tracking sets
- NewEmailIds.Remove(emailId);
- _knownEmailIds.Remove(emailId);
+ NewEmailIds.RemoveWhere(e => emailIds.Contains(e));
+ _knownEmailIds.RemoveWhere(e => emailIds.Contains(e));
+ CheckedEmailIds.Clear();
// Update total records
- TotalRecords = Math.Max(0, TotalRecords - 1);
+ TotalRecords = Math.Max(0, TotalRecords - emailIds.Count);
// Handle selection logic
- if (SelectedEmailId == emailId)
+ if (deletedSelectedEmailIndex >= 0)
{
SelectedEmailId = null;
SelectedEmail = null;
@@ -741,23 +782,23 @@ else
if (EmailList.Count > 0)
{
// If we deleted the first email, select the new first email
- if (deletedEmailIndex == 0)
+ if (deletedSelectedEmailIndex == 0)
{
var nextEmail = EmailList[0];
SelectedEmailId = nextEmail.Id;
await LoadSelectedEmailForPreview(nextEmail.Id);
}
// If we deleted an email in the middle, select the email at the same index (or the last one if index is out of bounds)
- else if (deletedEmailIndex > 0)
+ else if (deletedSelectedEmailIndex > 0)
{
- var newIndex = Math.Min(deletedEmailIndex, EmailList.Count - 1);
+ var newIndex = Math.Min(deletedSelectedEmailIndex, EmailList.Count - 1);
var nextEmail = EmailList[newIndex];
SelectedEmailId = nextEmail.Id;
await LoadSelectedEmailForPreview(nextEmail.Id);
}
}
}
-
+
StateHasChanged();
}
@@ -809,4 +850,102 @@ else
StateHasChanged();
}
}
+
+ /// <summary>
+ /// Show confirmation modal before deleting multiple emails.
+ /// </summary>
+ private async Task ShowBulkDeleteConfirmation()
+ {
+ if (CheckedEmailIds.Count == 0)
+ {
+ return;
+ }
+
+ var result = await ConfirmModalService.ShowConfirmation(
+ Localizer["BulkDeleteEmailTitle"],
+ string.Format(Localizer["BulkDeleteEmailConfirmation"], CheckedEmailIds.Count()),
+ SharedLocalizer["Confirm"],
+ SharedLocalizer["Cancel"]
+ );
+
+ if (result)
+ {
+ await DeleteAllCheckedEmails();
+ }
+ }
+
+ /// <summary>
+ /// Bulk delete all checked emails.
+ /// </summary>
+ private async Task DeleteAllCheckedEmails()
+ {
+ if (CheckedEmailIds.Count == 0)
+ {
+ return;
+ }
+
+ var requestModel = new EmailBulkRequest
+ {
+ Ids = CheckedEmailIds.ToList(),
+ };
+
+ var request = new HttpRequestMessage(HttpMethod.Delete, $"v1/Email/bulk");
+ request.Content = new StringContent(JsonSerializer.Serialize(requestModel), Encoding.UTF8, "application/json");
+
+ try
+ {
+ var response = await HttpClient.SendAsync(request);
+ if (response.IsSuccessStatusCode)
+ {
+ var emailBulkResponse = await response.Content.ReadFromJsonAsync<EmailBulkResponse>();
+ var successfulCount = emailBulkResponse?.SuccessfulEmailIds.Count;
+
+ if (successfulCount == CheckedEmailIds.Count)
+ {
+ // Notify all emails deleted successfully.
+ GlobalNotificationService.AddSuccessMessage(string.Format(Localizer["BulkDeleteEmailSuccess"], successfulCount), true);
+ }
+ else
+ {
+ // Notify some errors, some deleted
+ var errorCount = requestModel.Ids.Count() - successfulCount;
+ GlobalNotificationService.AddErrorMessage(string.Format(Localizer["BulkDeleteEmailFailedMessage"], successfulCount, errorCount), true);
+ }
+
+ // Handle each email successfully deleted
+ var successfulEmailIds = emailBulkResponse != null ? emailBulkResponse.SuccessfulEmailIds : [];
+ await HandleEmailsDeleted(successfulEmailIds);
+ }
+ else
+ {
+ var errorContent = await response.Content.ReadAsStringAsync();
+ var errorResponse = JsonSerializer.Deserialize<ApiErrorResponse>(errorContent);
+ switch (response.StatusCode)
+ {
+ case HttpStatusCode.BadRequest:
+ if (errorResponse != null)
+ {
+ switch (errorResponse.Code)
+ {
+ case "CLAIM_DOES_NOT_EXIST":
+ GlobalNotificationService.AddErrorMessage(Localizer["ClaimDoesNotExistError"], true);
+ break;
+ default:
+ throw new ArgumentException(errorResponse.Message);
+ }
+ }
+ break;
+ case HttpStatusCode.Unauthorized:
+ throw new UnauthorizedAccessException(errorResponse?.Message);
+ default:
+ throw new WebException(errorResponse?.Message);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ GlobalNotificationService.AddErrorMessage(ex.Message, true);
+ Logger.LogError(ex, "An error occurred while bulk deleting emails at server");
+ }
+ }
}
diff --git a/apps/server/AliasVault.Client/Main/Pages/Emails/Models/MailListViewModel.cs b/apps/server/AliasVault.Client/Main/Pages/Emails/Models/MailListViewModel.cs
index 378fe781e..1b91bf09a 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Emails/Models/MailListViewModel.cs
+++ b/apps/server/AliasVault.Client/Main/Pages/Emails/Models/MailListViewModel.cs
@@ -61,4 +61,9 @@ public class MailListViewModel
/// Gets or sets a value indicating whether the email has attachments.
/// </summary>
public bool HasAttachments { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the email is checked on list view.
+ /// </summary>
+ public bool IsChecked { get; set; } = false;
}
diff --git a/apps/server/AliasVault.Client/Resources/Pages/Main/Emails/Home.en.resx b/apps/server/AliasVault.Client/Resources/Pages/Main/Emails/Home.en.resx
index 1040e8c2b..491017c91 100644
--- a/apps/server/AliasVault.Client/Resources/Pages/Main/Emails/Home.en.resx
+++ b/apps/server/AliasVault.Client/Resources/Pages/Main/Emails/Home.en.resx
@@ -73,6 +73,26 @@
<data name="RefreshButton" xml:space="preserve">
<value>Refresh</value>
<comment>Refresh button text</comment>
+ </data>
+ <data name="DeleteSelectedEmails" xml:space="preserve">
+ <value>Delete {0} selected email(s)</value>
+ <comment>Delete selected emails button text</comment>
+ </data>
+ <data name="BulkDeleteEmailTitle" xml:space="preserve">
+ <value>Delete email(s)</value>
+ <comment>Delete multiple emails confirmation dialog title</comment>
+ </data>
+ <data name="BulkDeleteEmailConfirmation" xml:space="preserve">
+ <value>Are you sure you want to delete {0} email(s)? This action cannot be undone.</value>
+ <comment>Delete multiple emails confirmation message. {0} is placeholder for total number of to be deleted emails</comment>
+ </data>
+ <data name="BulkDeleteEmailSuccess" xml:space="preserve">
+ <value>All {0} email(s) deleted successfully</value>
+ <comment>Success message when multiple emails are deleted. {0} is placeholder for total number of deleted emails</comment>
+ </data>
+ <data name="BulkDeleteEmailFailedMessage" xml:space="preserve">
+ <value>Failed to delete multiple emails. Requested: {0}, deleted successfully: {1}.</value>
+ <comment>Error message when multiple emails are deleted. {0} is placeholder for total requested and {1} for the number of deleted emails</comment>
</data>
<data name="NoEmailClaimsMessage" xml:space="preserve">
<value>You are not using any private email addresses (yet). Create a new alias and use a private email address supported by AliasVault. All emails received by these private email addresses will show up here.</value>
diff --git a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css b/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
index b12f47037..df5847248 100644
--- a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
+++ b/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
@@ -2342,6 +2342,10 @@ video {
padding-left: 1.25rem;
}
+.pl-4 {
+ padding-left: 1rem;
+}
+
.pr-10 {
padding-right: 2.5rem;
}
@@ -2374,6 +2378,10 @@ video {
padding-top: 0px;
}
+.pt-1 {
+ padding-top: 0.25rem;
+}
+
.pt-16 {
padding-top: 4rem;
}
@@ -2799,9 +2807,7 @@ video {
}
.transition {
- transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
- transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms;
}
diff --git a/apps/server/Shared/AliasVault.RazorComponents/Buttons/DeleteAllSelectedButton.razor b/apps/server/Shared/AliasVault.RazorComponents/Buttons/DeleteAllSelectedButton.razor
new file mode 100644
index 000000000..913ad1777
--- /dev/null
+++ b/apps/server/Shared/AliasVault.RazorComponents/Buttons/DeleteAllSelectedButton.razor
@@ -0,0 +1,30 @@
+<Button OnClick="HandleClick"
+ Display="flex"
+ Color="danger">
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
+ </svg>
+ <span class="ml-2">@ButtonText</span>
+</Button>
+
+@code {
+ /// <summary>
+ /// The event to call in the parent when the delete button is clicked.
+ /// </summary>
+ [Parameter]
+ public EventCallback OnClick { get; set; }
+
+ /// <summary>
+ /// The text to display on the button.
+ /// </summary>
+ [Parameter]
+ public string ButtonText { get; set; } = "Delete All Selected";
+
+ /// <summary>
+ /// Handles the button click event.
+ /// </summary>
+ private async Task HandleClick()
+ {
+ await OnClick.InvokeAsync();
+ }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/Email/EmailBulkRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/Email/EmailBulkRequest.cs
new file mode 100644
index 000000000..6d307bb09
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/Email/EmailBulkRequest.cs
@@ -0,0 +1,19 @@
+//-----------------------------------------------------------------------
+// <copyright file="EmailBulkRequest.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Shared.Models.WebApi.Email;
+
+/// <summary>
+/// EmailBulkRequest model for retrieving recent emails from multiple emailboxes.
+/// </summary>
+public class EmailBulkRequest
+{
+ /// <summary>
+ /// Gets or sets the list of email IDs.
+ /// </summary>
+ public List<int> Ids { get; set; } = [];
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/Email/EmailBulkResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/Email/EmailBulkResponse.cs
new file mode 100644
index 000000000..d794c2503
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/Email/EmailBulkResponse.cs
@@ -0,0 +1,19 @@
+//-----------------------------------------------------------------------
+// <copyright file="EmailBulkResponse.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Shared.Models.WebApi.Email;
+
+/// <summary>
+/// Represents a email bulk actions API model.
+/// </summary>
+public class EmailBulkResponse
+{
+ /// <summary>
+ /// Gets or sets the emails that were deleted.
+ /// </summary>
+ public List<int> SuccessfulEmailIds { get; set; } = new();
+}