Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat: use image proxy service (#1719)
Will Hutchinson6fed17aa46ac
diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.tsindex f5b52c7132..274ac7d8b1 100644--- a/js/app/packages/core/constant/featureFlags.ts+++ b/js/app/packages/core/constant/featureFlags.ts@@ -128,3 +128,5 @@ export const ENABLE_EMAIL_SCHEDULED_SEND = false;export const ENABLE_AI_AUTO_TAB_ATTACHMENTS = true;export const ENABLE_FEATURED_SEARCH_RESULTS = true;++export const ENABLE_PROXY_EMAIL_IMAGES = DEV_MODE_ENV;diff --git a/js/app/packages/core/constant/servers.ts b/js/app/packages/core/constant/servers.tsindex e8952ead76..a26198368e 100644--- a/js/app/packages/core/constant/servers.ts+++ b/js/app/packages/core/constant/servers.ts@@ -10,6 +10,7 @@ const serverHostLocal: Servers = {'unfurl-service': 'http://localhost:8095',contacts: 'http://localhost:8083','email-service': 'http://localhost:8087',+ 'image-proxy-service': 'http://localhost:8097',} as const;const devServerSuffix = import.meta.env.MODE === 'development' ? '-dev' : '';@@ -26,6 +27,7 @@ const serverHostRemote = {'unfurl-service': `https://unfurl-service${devServerSuffix}.macro.com`,contacts: `https://contacts${devServerSuffix}.macro.com`,'email-service': `https://email-service${devServerSuffix}.macro.com`,+ 'image-proxy-service': `https://image-proxy${devServerSuffix}.macro.com`,} as const;type Servers = Record<keyof typeof serverHostRemote, string>;diff --git a/js/app/packages/core/email/index.ts b/js/app/packages/core/email/index.tsindex f9fcbe5437..10d11b5109 100644--- a/js/app/packages/core/email/index.ts+++ b/js/app/packages/core/email/index.ts@@ -5,6 +5,9 @@ export {type ParsedEmailContent,} from './parse-email-html';+// Image proxy utilities+export { proxyEmailImages } from './proxy-email-images';+// Color transformation utilitiesexport {processEmailColors,diff --git a/js/app/packages/core/email/parse-email-html.ts b/js/app/packages/core/email/parse-email-html.tsindex 9ca78f40ef..1431683079 100644--- a/js/app/packages/core/email/parse-email-html.ts+++ b/js/app/packages/core/email/parse-email-html.ts@@ -1,3 +1,6 @@+import { ENABLE_PROXY_EMAIL_IMAGES } from '../constant/featureFlags';+import { proxyEmailImages } from './proxy-email-images';+/*** Strips @media (prefers-color-scheme: ...) rules from CSS content.* This prevents email dark mode styles from conflicting with our forced backgrounds.@@ -168,9 +171,16 @@ export function parseEmailContent(? `${styleTags}\n${mainContentDiv.innerHTML}`: mainContentDiv.innerHTML;+ if (ENABLE_PROXY_EMAIL_IMAGES) {+ mainContent = proxyEmailImages(finalContent);+ signature = signature ? proxyEmailImages(signature) : null;+ } else {+ mainContent = finalContent;+ }+return {- mainContent: finalContent,- signature: signature,+ mainContent,+ signature,hasTable,};}diff --git a/js/app/packages/core/email/proxy-email-images.ts b/js/app/packages/core/email/proxy-email-images.tsnew file mode 100644index 0000000000..b6c40e6048--- /dev/null+++ b/js/app/packages/core/email/proxy-email-images.ts@@ -0,0 +1,23 @@+import { SERVER_HOSTS } from '../constant/servers';++/**+ * Serves images through image proxy service to avoid storing data.+ * Rewrites external `<img>` src attributes in HTML to route through the image proxy service.+ * Skips non-HTTP(S) schemes (e.g. `data:`).+ */+export function proxyEmailImages(html: string): string {+ const container = document.createElement('div');+ container.innerHTML = html;++ const images = container.querySelectorAll('img[src]');+ for (const img of images) {+ const src = img.getAttribute('src');+ if (!src) continue;+ if (!src.startsWith('http://') && !src.startsWith('https://')) continue;++ const proxiedUrl = `${SERVER_HOSTS['image-proxy-service']}/proxy?url=${encodeURIComponent(src)}`;+ img.setAttribute('src', proxiedUrl);+ }++ return container.innerHTML;+}