Files
webmail/lib/desktop/open-link.ts
T
Linus Rath e20aded171 fix: keep restored desktop composers off sent mail and on their own From, check links from the native menu, and fetch no dictionary without asking
A restored composer opened whatever the id named. Sending keeps the id, so its autosave would have destroyed the Sent copy, Send mailed it twice and Discard deleted it. It now needs the login in its address and a real draft, keeps its From with several accounts, and stays on the list if the server doesn't answer. A message from a bulwark:// link no longer marks itself read or sends a receipt. Native menus speak all 30 languages. Spellcheck dictionaries come from Google only after a yes, never in no-third-party mode.
2026-11-03 12:53:40 +01:00

23 lines
938 B
TypeScript

/**
* "Open Link" in the desktop app's native menu. It has to go where a click on the
* link goes: a mail address to the app's composer, anything else past
* resolveExternalLink, where a plugin can stop it or send it elsewhere.
*/
import { isOpenableLinkHref } from '@/lib/email-sanitization';
import { resolveExternalLink } from '@/lib/plugin-hook-result';
import { requestInternalMailto } from '@/lib/protocol-handlers/mailto';
import { getDesktopBridge } from './bridge';
export async function openLinkFromNativeMenu(href: string, text: string, emailId?: string): Promise<void> {
const shell = getDesktopBridge()?.shell;
if (!shell) return;
if (/^mailto:/i.test(href)) {
if (!requestInternalMailto(href)) shell.openExternal(href);
return;
}
if (!isOpenableLinkHref(href)) return;
const target = await resolveExternalLink({ href, target: '_blank', emailId, text });
if (target) shell.openExternal(target);
}