(download) add raw email download button

This commit is contained in:
Sylvain Zimmer
2025-10-14 23:53:02 +02:00
parent 7d4cd48669
commit 4b1d480d53
3 changed files with 17 additions and 0 deletions
@@ -99,6 +99,7 @@
"Domain admin": "Domain admin",
"Domain not found": "Domain not found",
"Download": "Download",
"Download raw email": "Download raw email",
"Draft": "Draft",
"Draft deleted": "Draft deleted",
"Draft saved": "Draft saved",
@@ -99,6 +99,7 @@
"Domain admin": "Gestion des domaines",
"Domain not found": "Domaine introuvable",
"Download": "Télécharger",
"Download raw email": "Télécharger l'email brut",
"Draft": "Brouillon",
"Draft deleted": "Brouillon supprimé",
"Draft saved": "Brouillon enregistré",
@@ -15,6 +15,8 @@ import { MessageFormMode } from "@/features/forms/components/message-form";
import MailHelper from "@/features/utils/mail-helper";
import useAbility, { Abilities } from "@/hooks/use-ability";
import { ContactChip } from "@/features/ui/components/contact-chip";
import { getMessagesEmlRetrieveUrl } from "@/features/api/gen/messages/messages";
import { getRequestUrl } from "@/features/api/utils";
type ThreadMessageProps = {
message: Message,
@@ -158,6 +160,19 @@ export const ThreadMessage = forwardRef<HTMLElement, ThreadMessageProps>(
icon: <span className="material-icons">mark_email_unread</span>,
callback: () => markAsUnreadFrom(message.id)
},
{
label: t('Download raw email'),
icon: <span className="material-icons">download</span>,
callback: () => {
const downloadUrl = getRequestUrl(getMessagesEmlRetrieveUrl(message.id));
const link = document.createElement('a');
link.href = downloadUrl;
link.download = `message-${message.id}.eml`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
},
...(message.is_trashed ? [] : [{
label: t('Delete'),
icon: <span className="material-icons">delete</span>,