Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update email format switcher logic and UI in web app (#150)
Leendert de Borst75a0a5ae724b
diff --git a/apps/server/AliasVault.Api/Controllers/Email/EmailController.cs b/apps/server/AliasVault.Api/Controllers/Email/EmailController.csindex 03686dddc..8a88923b0 100644--- a/apps/server/AliasVault.Api/Controllers/Email/EmailController.cs+++ b/apps/server/AliasVault.Api/Controllers/Email/EmailController.cs@@ -54,6 +54,7 @@ public class EmailController(ILogger<VaultController> logger, IAliasServerDbContSecondsAgo = (int)DateTime.UtcNow.Subtract(email.DateSystem).TotalSeconds,MessageHtml = email.MessageHtml,MessagePlain = email.MessagePlain,+ MessageSource = email.MessageSource,EncryptedSymmetricKey = email.EncryptedSymmetricKey,EncryptionKey = email.EncryptionKey.PublicKey,};diff --git a/apps/server/AliasVault.Client/Main/Components/Email/EmailModal.razor b/apps/server/AliasVault.Client/Main/Components/Email/EmailModal.razorindex 7bc6d9d99..4fadd49ec 100644--- a/apps/server/AliasVault.Client/Main/Components/Email/EmailModal.razor+++ b/apps/server/AliasVault.Client/Main/Components/Email/EmailModal.razor@@ -3,6 +3,8 @@@using AliasVault.Shared.Core;@using AliasVault.Client.Main.Components.Layout@using AliasVault.RazorComponents.Services+@using AliasClientDb.Models+@using Microsoft.EntityFrameworkCore@using Microsoft.Extensions.Localization@inject JsInteropService JsInteropService@inject GlobalNotificationService GlobalNotificationService@@ -11,65 +13,81 @@@inject HttpClient HttpClient@inject ConfirmModalService ConfirmModalService@inject IStringLocalizerFactory LocalizerFactory+@inject DbService DbService+@inject NavigationManager NavigationManager-<ClickOutsideHandler OnClose="OnClose" ContentId="emailModal">+<ClickOutsideHandler OnClose="OnClose" ContentId="emailModal,confirm-modal"><ModalWrapper OnEnter="Close">- <div id="emailModal" class="relative bg-white w-3/4 flex flex-col rounded-lg shadow-xl max-h-[90vh] border-2 border-gray-300 dark:border-gray-400">+ <div id="emailModal" class="relative bg-white dark:bg-gray-800 w-3/4 flex flex-col rounded-lg shadow-xl max-h-[90vh] border border-gray-200 dark:border-gray-700"><!-- Header -->- <div class="p-4 border-b">- <div class="flex items-center justify-between mb-3">- <h2 class="text-2xl font-bold text-gray-900">+ <div class="p-4 border-b border-gray-200 dark:border-gray-700">+ <div class="flex items-center justify-between gap-3 mb-3">+ <h2 class="text-2xl font-bold text-gray-900 dark:text-gray-100 truncate min-w-0">@if (IsSpamOk){- <a target="_blank" href="https://spamok.com/@(Email!.ToLocal)/@(Email!.Id)">@Email.Subject</a>+ <a target="_blank" href="https://spamok.com/@(Email!.ToLocal)/@(Email!.Id)" class="hover:underline">@Email.Subject</a>}else{<span>@Email?.Subject</span>}</h2>- <button @onclick="Close" class="text-gray-400 hover:text-gray-500">- <svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>- </svg>- </button>+ <div class="flex items-center gap-1 flex-shrink-0">+ @if (GetAvailableModes().Count > 1)+ {+ <ModalHeaderAction OnClick="CycleViewMode" Title="@SharedLocalizer["EmailFormatSwitchTitle"]">+ @CurrentFormatLabel+ </ModalHeaderAction>+ }+ <ModalHeaderAction OnClick="ShowDeleteConfirmation" Title="@Localizer["DeleteButton"]" Variant="ModalHeaderAction.ActionVariant.Danger">+ <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">+ <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"/>+ </svg>+ </ModalHeaderAction>+ <ModalHeaderAction OnClick="Close" Title="@SharedLocalizer["Close"]">+ <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>+ </svg>+ </ModalHeaderAction>+ </div></div>- <!-- 2-column layout for email details -->- <div class="grid grid-cols-1 sm:grid-cols-2 gap-4 text-sm text-gray-500 dark:text-gray-400">+ <!-- 2-column on desktop; on mobile the columns stack and flow as one continuous list. The second column gets mt-1 on mobile so the gap between Date/Item and From/To matches the space-y-1 used within each block. -->+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-x-4 text-sm text-gray-500 dark:text-gray-400"><div class="space-y-1"><p>@Localizer["FromLabel"] @(Email?.FromLocal)@@@(Email?.FromDomain)</p><p>@Localizer["ToLabel"] @(Email?.ToLocal)@@@(Email?.ToDomain)</p></div>- <div class="space-y-1">+ <div class="space-y-1 mt-1 sm:mt-0"><p>@Localizer["DateLabel"] @Email?.DateSystem</p>- <p>@Localizer["ActionsLabel"] <button @onclick="ShowDeleteConfirmation" class="text-red-500 hover:text-red-700 text-sm">@Localizer["DeleteButton"]</button></p>+ @if (ShowItemLink)+ {+ @if (!string.IsNullOrEmpty(_credentialName) && _credentialId != Guid.Empty)+ {+ <p>+ <span class="font-medium">@SharedLocalizer["EmailItemLabel"]</span>+ <button @onclick="NavigateToCredential"+ class="text-blue-600 hover:underline dark:text-blue-400 cursor-pointer">+ @_credentialName+ </button>+ </p>+ }+ else+ {+ <p>+ <span class="font-medium">@SharedLocalizer["EmailItemLabel"]</span>+ <span class="text-gray-400 dark:text-gray-500">@SharedLocalizer["EmailItemNone"]</span>+ </p>+ }+ }</div></div></div>- <!-- Format Switcher -->- <div class="px-4 py-2 border-b flex gap-1 bg-gray-50 dark:bg-gray-800">- <button @onclick="() => SetViewMode(EmailViewMode.Html)"- class="@(_viewMode == EmailViewMode.Html ? "px-3 py-1 text-sm font-medium rounded-md bg-blue-500 text-white" : "px-3 py-1 text-sm font-medium rounded-md text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700")"- disabled="@(string.IsNullOrWhiteSpace(Email?.MessageHtml))">- HTML- </button>- <button @onclick="() => SetViewMode(EmailViewMode.Plain)"- class="@(_viewMode == EmailViewMode.Plain ? "px-3 py-1 text-sm font-medium rounded-md bg-blue-500 text-white" : "px-3 py-1 text-sm font-medium rounded-md text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700")"- disabled="@(Email?.MessagePlain == null)">- Plain- </button>- <button @onclick="() => SetViewMode(EmailViewMode.Source)"- class="@(_viewMode == EmailViewMode.Source ? "px-3 py-1 text-sm font-medium rounded-md bg-blue-500 text-white" : "px-3 py-1 text-sm font-medium rounded-md text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700")">- Source- </button>- </div>-<!-- Scrollable Content --><div class="flex-1 overflow-y-auto p-4"><div class="text-gray-700 dark:text-gray-300"><div>- <iframe class="w-full overscroll-y-auto" style="height:500px;" srcdoc="@EmailBody" sandbox="allow-popups allow-popups-to-escape-sandbox">+ <iframe class="w-full overscroll-y-auto bg-white rounded" style="height:500px;" srcdoc="@EmailBody" sandbox="allow-popups allow-popups-to-escape-sandbox"></iframe></div></div>@@ -86,7 +104,7 @@<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"></path></svg><button @onclick="() => DownloadAttachment(attachment)"- class="text-primary hover:underline text-sm truncate attachment-link">+ class="text-primary-600 hover:underline text-sm truncate dark:text-primary-400 attachment-link">(@(Math.Ceiling((double)attachment.Filesize / 1024)) KB) @attachment.Filename</button></div>@@ -95,9 +113,6 @@</div>}</div>- <div class="mt-6 flex justify-end space-x-4">- <button id="close-email-modal" @onclick="Close" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">@Localizer["CloseButton"]</button>- </div></div></div></ModalWrapper>@@ -133,9 +148,23 @@public EventCallback<int> OnEmailDeleted { get; set; }/// <summary>- /// The available email view modes.+ /// When true, render the "Item:" row that links back to the associated credential. Defaults to false because+ /// when this modal is opened from an item-detail page the context is already clear. Callers that surface the+ /// modal from a cross-item list (e.g. the mobile emails page) should pass true; the modal then resolves and+ /// navigates to the credential itself based on the email's to-address./// </summary>- private enum EmailViewMode { Html, Plain, Source }+ [Parameter]+ public bool ShowItemLink { get; set; }++ /// <summary>+ /// Resolved credential ID for the email's to-address (only populated when ShowItemLink is true).+ /// </summary>+ private Guid _credentialId;++ /// <summary>+ /// Resolved credential name for the email's to-address (only populated when ShowItemLink is true).+ /// </summary>+ private string _credentialName = string.Empty;/// <summary>/// The currently selected view mode.@@ -265,6 +294,62 @@}}+ /// <summary>+ /// Returns the list of view modes that have content for the current email,+ /// in display order (HTML, Plain, Source).+ /// </summary>+ private List<EmailViewMode> GetAvailableModes()+ {+ var modes = new List<EmailViewMode>();+ var hasHtml = !string.IsNullOrWhiteSpace(Email?.MessageHtml);+ var hasPlain = Email?.MessagePlain != null;+ var hasSource = !string.IsNullOrWhiteSpace(Email?.MessageSource);+ if (hasHtml)+ {+ modes.Add(EmailViewMode.Html);+ }++ // Text is only offered when the server actually provided a plain-text part.+ if (hasPlain)+ {+ modes.Add(EmailViewMode.Plain);+ }++ // Source is always offered whenever there's any content.+ if (hasSource)+ {+ modes.Add(EmailViewMode.Source);+ }+ return modes;+ }++ /// <summary>+ /// Label for the currently active view mode, used as the cycle button caption.+ /// </summary>+ private string CurrentFormatLabel => _viewMode switch+ {+ EmailViewMode.Html => SharedLocalizer["EmailFormatHtml"],+ EmailViewMode.Plain => SharedLocalizer["EmailFormatPlain"],+ EmailViewMode.Source => SharedLocalizer["EmailFormatSource"],+ _ => string.Empty,+ };++ /// <summary>+ /// Cycle to the next available view mode.+ /// </summary>+ private void CycleViewMode()+ {+ var modes = GetAvailableModes();+ if (modes.Count <= 1)+ {+ return;+ }++ var currentIndex = modes.IndexOf(_viewMode);+ var nextIndex = (currentIndex + 1) % modes.Count;+ SetViewMode(modes[nextIndex]);+ }+/// <summary>/// Sets the email body based on the selected view mode./// </summary>@@ -302,10 +387,10 @@break;case EmailViewMode.Source:- if (!string.IsNullOrWhiteSpace(Email.MessageHtml))+ if (!string.IsNullOrWhiteSpace(Email.MessageSource)){- var escapedHtml = System.Net.WebUtility.HtmlEncode(Email.MessageHtml);- EmailBody = $"<pre style='font-family: monospace; white-space: pre-wrap; word-wrap: break-word; margin: 0; font-size: 12px; line-height: 1.4;'>{escapedHtml}</pre>";+ var escapedSource = System.Net.WebUtility.HtmlEncode(Email.MessageSource);+ EmailBody = $"<pre style='font-family: monospace; white-space: pre-wrap; word-wrap: break-word; margin: 0; font-size: 12px; line-height: 1.4;'>{escapedSource}</pre>";}else{@@ -337,6 +422,51 @@EmailBody = Localizer["NoEmailBody"];}}++ // Resolve the credential linked to this email's to-address when the caller asks for the+ // Item row. SpamOK emails aren't backed by a local vault item so the lookup is skipped.+ if (ShowItemLink && !IsSpamOk && Email != null)+ {+ await ResolveLinkedCredential();+ }+ }++ /// <summary>+ /// Look up the credential in the local vault whose login email matches this email's to-address.+ /// </summary>+ private async Task ResolveLinkedCredential()+ {+ if (Email == null)+ {+ return;+ }++ var toEmail = (Email.ToLocal + "@" + Email.ToDomain).ToLower();+ var context = await DbService.GetDbContextAsync();+ var item = await context.Items+ .Where(x => !x.IsDeleted && x.DeletedAt == null)+ .Where(x => x.FieldValues.Any(fv => fv.FieldKey == FieldKey.LoginEmail && fv.Value != null && fv.Value.ToLower() == toEmail && !fv.IsDeleted))+ .Select(x => new { x.Id, x.Name })+ .FirstOrDefaultAsync();++ if (item != null)+ {+ _credentialId = item.Id;+ _credentialName = item.Name ?? string.Empty;+ }+ }++ /// <summary>+ /// Navigate to the linked credential's detail page.+ /// </summary>+ private void NavigateToCredential()+ {+ if (_credentialId == Guid.Empty)+ {+ return;+ }++ NavigationManager.NavigateTo($"/items/{_credentialId}");}/// <summary>diff --git a/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razor b/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razorindex ff50af047..b25690e70 100644--- a/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razor+++ b/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razor@@ -28,11 +28,21 @@<span>@Email.Subject</span>}</h2>- <button @onclick="ShowDeleteConfirmation" id="delete-email" class="text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300">- <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">- <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"/>- </svg>- </button>+ <div class="flex items-center gap-2">+ @if (GetAvailableModes().Count > 1)+ {+ <button @onclick="CycleViewMode"+ title="@SharedLocalizer["EmailFormatSwitchTitle"]"+ class="text-xs font-medium px-2 py-1 rounded text-gray-600 hover:text-gray-800 hover:bg-gray-200 dark:text-gray-300 dark:hover:text-gray-100 dark:hover:bg-gray-600">+ @CurrentFormatLabel+ </button>+ }+ <button @onclick="ShowDeleteConfirmation" id="delete-email" class="text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300">+ <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">+ <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"/>+ </svg>+ </button>+ </div></div><!-- 2-column layout for email details --><div class="grid grid-cols-1 sm:grid-cols-2 gap-4 text-sm text-gray-600 dark:text-gray-300">@@ -44,7 +54,7 @@<p><span class="font-medium">@Localizer["DateLabel"]</span> @Email.DateSystem</p>@if (!string.IsNullOrEmpty(CredentialName) && CredentialId != Guid.Empty){- <p><span class="font-medium">@Localizer["ItemLabel"]</span>+ <p><span class="font-medium">@SharedLocalizer["EmailItemLabel"]</span><button @onclick="@(() => OnCredentialClick.InvokeAsync(CredentialId))"class="text-blue-600 hover:underline dark:text-blue-400 cursor-pointer">@CredentialName@@ -53,7 +63,7 @@}else{- <p><span class="font-medium">@Localizer["ItemLabel"]</span> <span class="text-gray-400 dark:text-gray-500">@Localizer["NoneValue"]</span></p>+ <p><span class="font-medium">@SharedLocalizer["EmailItemLabel"]</span> <span class="text-gray-400 dark:text-gray-500">@SharedLocalizer["EmailItemNone"]</span></p>}</div></div>@@ -146,6 +156,11 @@[Parameter]public EventCallback<Guid> OnCredentialClick { get; set; }+ /// <summary>+ /// The currently selected view mode.+ /// </summary>+ private EmailViewMode _viewMode = EmailViewMode.Html;+/// <summary>/// The message body to display/// </summary>@@ -266,27 +281,126 @@if (Email != null){- // Check if there is HTML content, if not, then set default viewtype to plain- if (Email.MessageHtml is not null && !string.IsNullOrWhiteSpace(Email.MessageHtml))+ // Pick an initial view mode based on what content is available.+ if (!string.IsNullOrWhiteSpace(Email.MessageHtml)){- // HTML is available, sanitize and prepare for display- EmailBody = ConversionUtility.SanitizeAndPrepareEmailHtml(Email.MessageHtml);+ SetViewMode(EmailViewMode.Html);}- else if (Email.MessagePlain is not null)+ else if (Email.MessagePlain != null){- // No HTML but plain text is available- // Escape HTML entities and wrap in pre tag to preserve formatting- var escapedText = System.Net.WebUtility.HtmlEncode(Email.MessagePlain);- EmailBody = $"<pre style='font-family: system-ui, -apple-system, sans-serif; white-space: pre-wrap; word-wrap: break-word; margin: 0;'>{escapedText}</pre>";+ SetViewMode(EmailViewMode.Plain);}else{- // No HTML and no plain text availableEmailBody = Localizer["NoEmailBody"];}}}+ /// <summary>+ /// Returns the list of view modes that have content for the current email,+ /// in display order (HTML, Plain, Source).+ /// </summary>+ private List<EmailViewMode> GetAvailableModes()+ {+ var modes = new List<EmailViewMode>();+ if (Email != null && !string.IsNullOrWhiteSpace(Email.MessageHtml))+ {+ modes.Add(EmailViewMode.Html);+ }++ if (Email?.MessagePlain != null)+ {+ modes.Add(EmailViewMode.Plain);+ }++ // Source shows the raw RFC 822 message captured by the SMTP service. Only offer it when+ // the server actually provided one — we never synthesise the source ourselves.+ if (!string.IsNullOrWhiteSpace(Email?.MessageSource))+ {+ modes.Add(EmailViewMode.Source);+ }+ return modes;+ }++ /// <summary>+ /// Label for the currently active view mode, used as the cycle button caption.+ /// </summary>+ private string CurrentFormatLabel => _viewMode switch+ {+ EmailViewMode.Html => SharedLocalizer["EmailFormatHtml"],+ EmailViewMode.Plain => SharedLocalizer["EmailFormatPlain"],+ EmailViewMode.Source => SharedLocalizer["EmailFormatSource"],+ _ => string.Empty,+ };++ /// <summary>+ /// Cycle to the next available view mode.+ /// </summary>+ private void CycleViewMode()+ {+ var modes = GetAvailableModes();+ if (modes.Count <= 1)+ {+ return;+ }++ var currentIndex = modes.IndexOf(_viewMode);+ var nextIndex = (currentIndex + 1) % modes.Count;+ SetViewMode(modes[nextIndex]);+ }++ /// <summary>+ /// Sets the email body based on the selected view mode.+ /// </summary>+ private void SetViewMode(EmailViewMode mode)+ {+ _viewMode = mode;+ if (Email == null)+ {+ return;+ }++ switch (mode)+ {+ case EmailViewMode.Html:+ if (!string.IsNullOrWhiteSpace(Email.MessageHtml))+ {+ EmailBody = ConversionUtility.SanitizeAndPrepareEmailHtml(Email.MessageHtml);+ }+ else+ {+ EmailBody = Localizer["NoEmailBody"];+ }++ break;+ case EmailViewMode.Plain:+ if (Email.MessagePlain != null)+ {+ var escapedText = System.Net.WebUtility.HtmlEncode(Email.MessagePlain);+ EmailBody = $"<pre style='font-family: system-ui, -apple-system, sans-serif; white-space: pre-wrap; word-wrap: break-word; margin: 0;'>{escapedText}</pre>";+ }+ else+ {+ EmailBody = Localizer["NoEmailBody"];+ }++ break;+ case EmailViewMode.Source:+ if (!string.IsNullOrWhiteSpace(Email.MessageSource))+ {+ var escapedSource = System.Net.WebUtility.HtmlEncode(Email.MessageSource);+ EmailBody = $"<pre style='font-family: monospace; white-space: pre-wrap; word-wrap: break-word; margin: 0; font-size: 12px; line-height: 1.4;'>{escapedSource}</pre>";+ }+ else+ {+ EmailBody = Localizer["NoEmailBody"];+ }++ break;+ }+ }+/// <summary>/// Download an attachment./// </summary>diff --git a/apps/server/AliasVault.Client/Main/Components/Email/EmailViewMode.cs b/apps/server/AliasVault.Client/Main/Components/Email/EmailViewMode.csnew file mode 100644index 000000000..b3eec175a--- /dev/null+++ b/apps/server/AliasVault.Client/Main/Components/Email/EmailViewMode.cs@@ -0,0 +1,23 @@+//-----------------------------------------------------------------------+// <copyright file="EmailViewMode.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.Client.Main.Components.Email;++/// <summary>+/// Available view modes for rendering an email body.+/// </summary>+public enum EmailViewMode+{+ /// <summary>Rendered HTML (sanitized) in a sandboxed iframe.</summary>+ Html,++ /// <summary>Plain-text part rendered with a sans-serif font.</summary>+ Plain,++ /// <summary>Raw email source content as received by the email server.</summary>+ Source,+}diff --git a/apps/server/AliasVault.Client/Main/Components/Layout/ModalHeaderAction.razor b/apps/server/AliasVault.Client/Main/Components/Layout/ModalHeaderAction.razornew file mode 100644index 000000000..7358f43c2--- /dev/null+++ b/apps/server/AliasVault.Client/Main/Components/Layout/ModalHeaderAction.razor@@ -0,0 +1,48 @@+@*+ A single action button rendered in the action cluster of a modal header.+*@++<button type="button" @onclick="OnClick" title="@Title" class="@ButtonClass">+ @ChildContent+</button>++@code {+ /// <summary>+ /// Visual variant of the button. Default = neutral gray, Danger = red.+ /// </summary>+ public enum ActionVariant+ {+ Default,+ Danger,+ }++ /// <summary>+ /// Button content (icon SVG or short text).+ /// </summary>+ [Parameter]+ public RenderFragment? ChildContent { get; set; }++ /// <summary>+ /// Tooltip / accessible label.+ /// </summary>+ [Parameter]+ public string? Title { get; set; }++ /// <summary>+ /// Click handler.+ /// </summary>+ [Parameter]+ public EventCallback OnClick { get; set; }++ /// <summary>+ /// Visual variant.+ /// </summary>+ [Parameter]+ public ActionVariant Variant { get; set; } = ActionVariant.Default;++ private string ButtonClass => Variant switch+ {+ ActionVariant.Danger => "inline-flex items-center justify-center h-9 min-w-[2.25rem] px-2 rounded text-sm font-medium text-red-500 hover:text-red-600 hover:bg-gray-100 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-gray-700",+ _ => "inline-flex items-center justify-center h-9 min-w-[2.25rem] px-2 rounded text-sm font-medium text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700",+ };+}diff --git a/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor b/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razorindex b19a3291a..dee8a8aae 100644--- a/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor+++ b/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor@@ -20,7 +20,7 @@@if (EmailModalVisible){- <EmailModal Email="EmailModalEmail" IsSpamOk="false" OnClose="CloseEmailModal" OnEmailDeleted="HandleEmailDeletedFromModal" />+ <EmailModal Email="EmailModalEmail" IsSpamOk="false" OnClose="CloseEmailModal" OnEmailDeleted="HandleEmailDeletedFromModal" ShowItemLink="true" />}<PageHeader@@ -171,8 +171,8 @@ elseEmail="SelectedEmail"IsSpamOk="false"OnEmailDeleted="HandleEmailDeleted"- CredentialId="@GetSelectedEmailCredentialId()"- CredentialName="@GetSelectedEmailCredentialName()"+ CredentialId="@GetCredentialIdForEmail(SelectedEmailId)"+ CredentialName="@GetCredentialNameForEmail(SelectedEmailId)"OnCredentialClick="NavigateToCredential" /></div></div>@@ -713,25 +713,19 @@ else}/// <summary>- /// Get the credential ID for the currently selected email.+ /// Get the credential ID for the email with the given id, or Guid.Empty if not found./// </summary>- private Guid GetSelectedEmailCredentialId()+ private Guid GetCredentialIdForEmail(int? emailId){- if (SelectedEmailId == null) return Guid.Empty;-- var selectedEmailListItem = EmailList.FirstOrDefault(e => e.Id == SelectedEmailId);- return selectedEmailListItem?.CredentialId ?? Guid.Empty;+ return emailId is null ? Guid.Empty : EmailList.FirstOrDefault(e => e.Id == emailId)?.CredentialId ?? Guid.Empty;}/// <summary>- /// Get the credential name for the currently selected email.+ /// Get the credential name for the email with the given id, or an empty string if not found./// </summary>- private string GetSelectedEmailCredentialName()+ private string GetCredentialNameForEmail(int? emailId){- if (SelectedEmailId == null) return string.Empty;-- var selectedEmailListItem = EmailList.FirstOrDefault(e => e.Id == SelectedEmailId);- return selectedEmailListItem?.CredentialName ?? string.Empty;+ return emailId is null ? string.Empty : EmailList.FirstOrDefault(e => e.Id == emailId)?.CredentialName ?? string.Empty;}/// <summary>diff --git a/apps/server/AliasVault.Client/Resources/Components/Main/Email/EmailPreview.en.resx b/apps/server/AliasVault.Client/Resources/Components/Main/Email/EmailPreview.en.resxindex 9222c0c21..ae3fb2513 100644--- a/apps/server/AliasVault.Client/Resources/Components/Main/Email/EmailPreview.en.resx+++ b/apps/server/AliasVault.Client/Resources/Components/Main/Email/EmailPreview.en.resx@@ -70,14 +70,6 @@<value>Date:</value><comment>Email date field label</comment></data>- <data name="ItemLabel" xml:space="preserve">- <value>Item:</value>- <comment>Email item field label</comment>- </data>- <data name="NoneValue" xml:space="preserve">- <value>None</value>- <comment>No item assigned value</comment>- </data><data name="AttachmentsLabel" xml:space="preserve"><value>Attachments:</value><comment>Email attachments section header</comment>diff --git a/apps/server/AliasVault.Client/Resources/SharedResources.en.resx b/apps/server/AliasVault.Client/Resources/SharedResources.en.resxindex a60bff11a..ef7fc165c 100644--- a/apps/server/AliasVault.Client/Resources/SharedResources.en.resx+++ b/apps/server/AliasVault.Client/Resources/SharedResources.en.resx@@ -343,4 +343,28 @@<value>Loading vault...</value><comment>Status text when vault is being loaded</comment></data>+ <data name="EmailFormatHtml" xml:space="preserve">+ <value>HTML</value>+ <comment>Email format switcher: HTML view button. Shared between email modal and email page.</comment>+ </data>+ <data name="EmailFormatPlain" xml:space="preserve">+ <value>Text</value>+ <comment>Email format switcher: plain text view button. Shared between email modal and email page.</comment>+ </data>+ <data name="EmailFormatSource" xml:space="preserve">+ <value>Source</value>+ <comment>Email format switcher: raw HTML source view button. Shared between email modal and email page.</comment>+ </data>+ <data name="EmailFormatSwitchTitle" xml:space="preserve">+ <value>Switch email format</value>+ <comment>Tooltip for the cycle button that switches between HTML / Text / Source views. Shared between email modal and email page.</comment>+ </data>+ <data name="EmailItemLabel" xml:space="preserve">+ <value>Item:</value>+ <comment>Label for the credential/item row in the email header. Shared between email modal and email page.</comment>+ </data>+ <data name="EmailItemNone" xml:space="preserve">+ <value>None</value>+ <comment>Shown next to the Item label when an email is not linked to any credential. Shared between email modal and email page.</comment>+ </data></root>\ No newline at end of filediff --git a/apps/server/AliasVault.Client/Services/EmailService.cs b/apps/server/AliasVault.Client/Services/EmailService.csindex 2d66432ee..33aa391b3 100644--- a/apps/server/AliasVault.Client/Services/EmailService.cs+++ b/apps/server/AliasVault.Client/Services/EmailService.cs@@ -145,6 +145,11 @@ public sealed class EmailService(DbService dbService, JsInteropService jsInteropemail.MessagePlain = await jsInteropService.SymmetricDecrypt(email.MessagePlain, decryptedSymmetricKeyBase64);}+ if (email.MessageSource is not null)+ {+ email.MessageSource = await jsInteropService.SymmetricDecrypt(email.MessageSource, decryptedSymmetricKeyBase64);+ }+email.FromDisplay = await jsInteropService.SymmetricDecrypt(email.FromDisplay, decryptedSymmetricKeyBase64);email.FromLocal = await jsInteropService.SymmetricDecrypt(email.FromLocal, decryptedSymmetricKeyBase64);email.FromDomain = await jsInteropService.SymmetricDecrypt(email.FromDomain, decryptedSymmetricKeyBase64);diff --git a/apps/server/Shared/AliasVault.RazorComponents/ConfirmModal.razor b/apps/server/Shared/AliasVault.RazorComponents/ConfirmModal.razorindex 8fcf97298..c97d39b65 100644--- a/apps/server/Shared/AliasVault.RazorComponents/ConfirmModal.razor+++ b/apps/server/Shared/AliasVault.RazorComponents/ConfirmModal.razor@@ -4,7 +4,7 @@@if (ModalService.IsVisible){- <div class="fixed inset-0 z-[1000] bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full flex items-center justify-center">+ <div id="confirm-modal" class="fixed inset-0 z-[1000] bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full flex items-center justify-center"><div class="relative p-5 border w-96 shadow-lg rounded-md bg-white"><div class="mt-3 text-center"><h3 class="text-lg leading-6 font-medium text-gray-900">@ModalService.Title</h3>diff --git a/apps/server/Shared/AliasVault.Shared/Models/Spamok/EmailApiModel.cs b/apps/server/Shared/AliasVault.Shared/Models/Spamok/EmailApiModel.csindex 06b26d73e..63c50d4bc 100644--- a/apps/server/Shared/AliasVault.Shared/Models/Spamok/EmailApiModel.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/Spamok/EmailApiModel.cs@@ -24,6 +24,11 @@ public class EmailApiModel : EmailApiModelBase/// </summary>public string? MessagePlain { get; set; }+ /// <summary>+ /// Gets or sets the source content of the email message.+ /// </summary>+ public string? MessageSource { get; set; }+/// <summary>/// Gets or sets the list of attachments in the email./// </summary>