@open-workspace/email 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/alchemy/index.ts +130 -2
- package/drizzle/mailbox/0002_good_komodo.sql +2 -0
- package/drizzle/mailbox/0003_after_0_4_2.sql +180 -0
- package/drizzle/mailbox/meta/0002_snapshot.json +1017 -0
- package/drizzle/mailbox/meta/0003_snapshot.json +1507 -0
- package/drizzle/mailbox/meta/_journal.json +14 -0
- package/drizzle/mailbox/migrations.js +5 -1
- package/migrations/0001_overrated_ricochet.sql +2 -0
- package/migrations/0002_after_0_4_2.sql +35 -0
- package/migrations/meta/0001_snapshot.json +564 -0
- package/migrations/meta/0002_snapshot.json +807 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +23 -7
- package/shared/attachment-preview.ts +18 -8
- package/shared/folder-order.ts +31 -6
- package/shared/mail-headers.ts +3 -3
- package/shared/mail-html.ts +25 -0
- package/shared/mail-import.ts +0 -7
- package/shared/mail-received.ts +4 -4
- package/shared/mail-rule-actions.ts +47 -0
- package/shared/mail.ts +70 -4
- package/shared/office-preview.ts +0 -4
- package/shared/pdfjs-assets.ts +1 -3
- package/shared/rich-content.ts +35 -0
- package/shared/signature.ts +15 -0
- package/src/admin/address-auto-reply.tsx +49 -0
- package/src/admin/blocked-senders.tsx +86 -66
- package/src/admin/forward-destinations.tsx +140 -0
- package/src/admin/mail-archive.tsx +134 -0
- package/src/admin/team-signature.tsx +90 -0
- package/src/client.tsx +130 -16
- package/src/mail/attachment-preview-dialog.tsx +13 -5
- package/src/mail/auto-reply-banner.tsx +61 -0
- package/src/mail/blocked-senders.tsx +124 -91
- package/src/mail/compose-window-chrome.tsx +20 -8
- package/src/mail/compose-window.tsx +387 -365
- package/src/mail/composer-asset-bookmarks.ts +47 -12
- package/src/mail/composer-attachment-list.tsx +42 -17
- package/src/mail/composer-editor-document.ts +54 -10
- package/src/mail/composer-editor.tsx +44 -44
- package/src/mail/composer-link-text.ts +42 -0
- package/src/mail/composer-recipient-fields.tsx +25 -16
- package/src/mail/composer-recipients.ts +62 -16
- package/src/mail/composer-session.ts +107 -23
- package/src/mail/composer-toolbar.tsx +15 -1
- package/src/mail/composer-upload-client.ts +29 -1
- package/src/mail/composer-upload-progress.ts +2 -2
- package/src/mail/conversation-actions-model.ts +56 -0
- package/src/mail/conversation-list.tsx +263 -128
- package/src/mail/conversation-loading-skeleton.tsx +165 -90
- package/src/mail/conversation-message.tsx +257 -102
- package/src/mail/conversation-order.ts +12 -0
- package/src/mail/conversation-reply.tsx +313 -189
- package/src/mail/conversation-selection-toolbar.tsx +188 -143
- package/src/mail/conversation-view.tsx +320 -85
- package/src/mail/delivery-indicator.tsx +33 -12
- package/src/mail/draft-attachments.ts +194 -0
- package/src/mail/email-html-body.tsx +97 -53
- package/src/mail/folder-cleanup-bar.tsx +193 -0
- package/src/mail/folder-glyph.tsx +5 -0
- package/src/mail/folder-manager.tsx +71 -38
- package/src/mail/mail-app-bar.tsx +15 -3
- package/src/mail/mail-dock.tsx +19 -3
- package/src/mail/mail-focus.ts +48 -0
- package/src/mail/mail-folders.ts +14 -2
- package/src/mail/mail-layout.css +20 -0
- package/src/mail/mail-mailbox-sheet.tsx +22 -69
- package/src/mail/mail-nav-rail.tsx +7 -4
- package/src/mail/mail-nav.tsx +66 -46
- package/src/mail/mail-prefetch.ts +30 -9
- package/src/mail/mail-primitives.tsx +6 -4
- package/src/mail/mail-queries.ts +122 -20
- package/src/mail/mail-query-cache.ts +1085 -173
- package/src/mail/mail-search-params.ts +35 -0
- package/src/mail/mail-shell.tsx +32 -9
- package/src/mail/mailbox-ai-settings.tsx +56 -42
- package/src/mail/mailbox-realtime.tsx +4 -12
- package/src/mail/mailbox-rules.tsx +898 -0
- package/src/mail/message-actions.tsx +38 -26
- package/src/mail/message-attachments.tsx +20 -12
- package/src/mail/message-body.ts +53 -0
- package/src/mail/message-format.ts +8 -2
- package/src/mail/message-header.tsx +3 -1
- package/src/mail/message-translation.tsx +34 -67
- package/src/mail/original-message-sheet.tsx +63 -50
- package/src/mail/original-message.ts +6 -6
- package/src/mail/pane-splitter.tsx +3 -3
- package/src/mail/pdf-preview.tsx +70 -62
- package/src/mail/plain-message-text.tsx +28 -0
- package/src/mail/print-message.ts +31 -36
- package/src/mail/reader-pane.tsx +134 -102
- package/src/mail/recipient-combobox.tsx +52 -29
- package/src/mail/recipient-field-row.tsx +3 -0
- package/src/mail/rich-content.ts +128 -0
- package/src/mail/sanitize-email-html.ts +57 -33
- package/src/mail/sender-actions.tsx +49 -39
- package/src/mail/sender-authentication.tsx +1 -1
- package/src/mail/sender-dialogs.tsx +67 -43
- package/src/mail/sender-security.tsx +9 -10
- package/src/mail/signature.ts +43 -0
- package/src/mail/translation-html.ts +3 -3
- package/src/mail/types.ts +12 -0
- package/src/mail/use-composer-attachment-preflight.ts +23 -60
- package/src/mail/use-composer-core.ts +286 -0
- package/src/mail/use-composer-navigation.ts +120 -0
- package/src/mail/use-composer-submission.ts +154 -19
- package/src/mail/use-conversation-actions.ts +292 -0
- package/src/mail/use-conversation-position.ts +51 -0
- package/src/mail/use-conversation-selection.ts +192 -89
- package/src/mail/use-draft-autosave.ts +394 -0
- package/src/mail/use-drafts.ts +194 -0
- package/src/mail/use-mail-controller.ts +754 -213
- package/src/mail/use-mail-data.ts +210 -100
- package/src/mail/use-mail-safety.ts +19 -38
- package/src/mail/use-mail-send.ts +18 -6
- package/src/mail/use-pdf-translation.ts +1 -1
- package/src/mail/use-reply-cc.ts +61 -0
- package/src/mail/use-visible-message-read.ts +128 -64
- package/src/pwa/push-key.ts +18 -0
- package/src/pwa/push-subscription.ts +88 -26
- package/src/settings/auto-reply-editor.tsx +454 -0
- package/src/settings/auto-reply-page.tsx +59 -0
- package/src/settings/mail-apps-page.tsx +52 -43
- package/src/settings/notifications-page.tsx +82 -67
- package/src/settings/rich-content-editor.tsx +182 -0
- package/src/settings/settings-queries.ts +57 -0
- package/src/settings/signature-editor.tsx +142 -0
- package/src/settings/signature-page.tsx +70 -0
- package/worker/admin/blocked-sender-routes.ts +10 -16
- package/worker/backups/eml.ts +185 -0
- package/worker/backups/file-parts.ts +140 -0
- package/worker/backups/mail-backup.ts +644 -0
- package/worker/backups/settings-backup.ts +866 -0
- package/worker/backups/stream-eml.ts +73 -0
- package/worker/db/schema.ts +98 -2
- package/worker/jmap/attachment-blobs.ts +113 -0
- package/worker/jmap/blobs.ts +162 -0
- package/worker/jmap/draft-content.ts +42 -0
- package/worker/jmap/drafts.ts +70 -0
- package/worker/jmap/email-body.ts +152 -0
- package/worker/jmap/email-methods.ts +1223 -0
- package/worker/jmap/eventsource.ts +9 -8
- package/worker/jmap/import-methods.ts +205 -0
- package/worker/jmap/mailbox-methods.ts +187 -0
- package/worker/jmap/method-core.ts +379 -0
- package/worker/jmap/methods.ts +108 -1815
- package/worker/jmap/push-subscription-methods.ts +373 -0
- package/worker/jmap/push-types.ts +46 -2
- package/worker/jmap/push.ts +24 -31
- package/worker/jmap/routes.ts +144 -153
- package/worker/jmap/submission-methods.ts +395 -0
- package/worker/mail/access.ts +35 -12
- package/worker/mail/ai-classification.ts +2 -2
- package/worker/mail/archive-object.ts +96 -0
- package/worker/mail/archive-routes.ts +35 -0
- package/worker/mail/archive.ts +682 -0
- package/worker/mail/auth-headers.ts +48 -40
- package/worker/mail/auto-reply-routes.ts +255 -0
- package/worker/mail/auto-reply.ts +243 -0
- package/worker/mail/bimi.ts +53 -36
- package/worker/mail/bootstrap.ts +11 -3
- package/worker/mail/capabilities.ts +69 -0
- package/worker/mail/classification-signals.ts +1 -1
- package/worker/mail/confusables-data.ts +9 -0
- package/worker/mail/conversation-cursor.ts +6 -15
- package/worker/mail/delivery-events.ts +9 -7
- package/worker/mail/delivery-facts.ts +1 -1
- package/worker/mail/demo-routes.ts +3 -3
- package/worker/mail/doh.ts +3 -3
- package/worker/mail/download-links.ts +153 -0
- package/worker/mail/downloads.ts +2 -6
- package/worker/mail/draft-routes.ts +473 -0
- package/worker/mail/draft-sender.ts +54 -0
- package/worker/mail/edge-cache.ts +41 -55
- package/worker/mail/email-routing.ts +123 -0
- package/worker/mail/forward-destinations.ts +114 -0
- package/worker/mail/forward-downloads.ts +115 -0
- package/worker/mail/forward-html.ts +85 -0
- package/worker/mail/header-metadata.ts +2 -5
- package/worker/mail/impersonation.ts +102 -101
- package/worker/mail/import-routes.ts +29 -82
- package/worker/mail/import.ts +130 -0
- package/worker/mail/inbound-delivery.ts +6 -5
- package/worker/mail/inbound.ts +58 -28
- package/worker/mail/ip-intel.ts +8 -17
- package/worker/mail/isolate-cache.ts +1 -1
- package/worker/mail/mailbox-deletion.ts +33 -12
- package/worker/mail/mailbox-directory.ts +39 -65
- package/worker/mail/mailing-list.ts +29 -58
- package/worker/mail/message-security.ts +3 -3
- package/worker/mail/message-view.ts +12 -10
- package/worker/mail/office-conversion.ts +3 -5
- package/worker/mail/office-preview-container.ts +3 -8
- package/worker/mail/outbound-content.ts +139 -65
- package/worker/mail/outbound-delivery.ts +20 -17
- package/worker/mail/outbound-service.ts +34 -9
- package/worker/mail/outbound.ts +146 -75
- package/worker/mail/outgoing-context.ts +60 -30
- package/worker/mail/participants.ts +10 -15
- package/worker/mail/plain-body.ts +39 -0
- package/worker/mail/push-endpoint.ts +17 -0
- package/worker/mail/push-notifications.ts +87 -43
- package/worker/mail/quote-parser.ts +107 -25
- package/worker/mail/r2-presigned-urls.ts +7 -0
- package/worker/mail/receive.ts +146 -39
- package/worker/mail/recipients.ts +1 -1
- package/worker/mail/remote-proxy.ts +3 -3
- package/worker/mail/repeat.ts +1 -1
- package/worker/mail/reply-plan.ts +124 -26
- package/worker/mail/rfc.ts +15 -7
- package/worker/mail/rich-content.ts +207 -0
- package/worker/mail/routes.ts +696 -304
- package/worker/mail/routing.ts +274 -0
- package/worker/mail/rules.ts +230 -0
- package/worker/mail/safety-routes.ts +88 -80
- package/worker/mail/schemas.ts +222 -31
- package/worker/mail/search.ts +25 -2
- package/worker/mail/security-settings.ts +4 -10
- package/worker/mail/send-message.ts +238 -0
- package/worker/mail/sender-intel.ts +12 -20
- package/worker/mail/signature-routes.ts +201 -0
- package/worker/mail/signatures.ts +195 -0
- package/worker/mail/spamhaus.ts +28 -16
- package/worker/mail/storage-keys.ts +35 -0
- package/worker/mail/unsubscribe.ts +19 -41
- package/worker/mail/uploads.ts +193 -80
- package/worker/mail/webhook-source.ts +3 -2
- package/worker/mail/workspace-safety.ts +194 -60
- package/worker/mailbox/demo.ts +13 -15
- package/worker/mailbox/email-index.ts +92 -13
- package/worker/mailbox/folder-model.ts +0 -20
- package/worker/mailbox/import-placement.ts +21 -36
- package/worker/mailbox/inbound-decision.ts +114 -0
- package/worker/mailbox/inbox-counts.ts +45 -25
- package/worker/mailbox/index.ts +843 -2888
- package/worker/mailbox/jmap-change-log.ts +195 -0
- package/worker/mailbox/jmap-email-rows.ts +186 -0
- package/worker/mailbox/jmap-mailboxes.ts +116 -0
- package/worker/mailbox/jmap-placement.ts +139 -0
- package/worker/mailbox/jmap-query-filter.ts +231 -0
- package/worker/mailbox/jmap-store.ts +167 -299
- package/worker/mailbox/mailbox-auto-reply.ts +301 -0
- package/worker/mailbox/mailbox-backup.ts +538 -0
- package/worker/mailbox/mailbox-drafts.ts +417 -0
- package/worker/mailbox/mailbox-folders.ts +242 -0
- package/worker/mailbox/mailbox-import.ts +450 -0
- package/worker/mailbox/mailbox-inbound.ts +934 -0
- package/worker/mailbox/mailbox-jmap.ts +294 -0
- package/worker/mailbox/mailbox-outbound.ts +413 -0
- package/worker/mailbox/mailbox-rules.ts +336 -0
- package/worker/mailbox/mailbox-senders.ts +294 -0
- package/worker/mailbox/mailbox-storage.ts +438 -0
- package/worker/mailbox/mailbox-views.ts +891 -0
- package/worker/mailbox/model.ts +1 -0
- package/worker/mailbox/office-preview-jobs.ts +59 -47
- package/worker/mailbox/placement.ts +933 -0
- package/worker/mailbox/restore-thread.ts +52 -0
- package/worker/mailbox/retention.ts +36 -0
- package/worker/mailbox/schema.ts +211 -1
- package/worker/mailbox/senders.ts +216 -178
- package/worker/mailbox/spam-undo-filing.ts +138 -0
- package/worker/mailbox/spam-undo.ts +240 -0
- package/worker/mailbox/support.ts +416 -0
- package/worker/mcp/mail-action-tools.ts +156 -0
- package/worker/mcp/mail-compose-tools.ts +8 -2
- package/worker/mcp/mail-safety-tools.ts +4 -4
- package/worker/module.ts +23 -2
- package/src/mail/use-compose-submission.ts +0 -208
- package/src/mail/use-reply-submission.ts +0 -114
- package/worker/mail/capped-body.ts +0 -36
|
@@ -8,6 +8,20 @@
|
|
|
8
8
|
"when": 1794374467122,
|
|
9
9
|
"tag": "0000_dry_moon_knight",
|
|
10
10
|
"breakpoints": true
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idx": 1,
|
|
14
|
+
"version": "6",
|
|
15
|
+
"when": 1794576500541,
|
|
16
|
+
"tag": "0001_overrated_ricochet",
|
|
17
|
+
"breakpoints": true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"idx": 2,
|
|
21
|
+
"version": "6",
|
|
22
|
+
"when": 1795144622538,
|
|
23
|
+
"tag": "0002_after_0_4_2",
|
|
24
|
+
"breakpoints": true
|
|
11
25
|
}
|
|
12
26
|
]
|
|
13
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-workspace/email",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Team mail for OpenWorkspace: personal and shared inboxes, mailing lists, previews, safety, and AI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"alchemy",
|
|
@@ -33,23 +33,32 @@
|
|
|
33
33
|
".": "./index.ts",
|
|
34
34
|
"./alchemy": "./alchemy/index.ts",
|
|
35
35
|
"./client": "./src/client.tsx",
|
|
36
|
-
"
|
|
36
|
+
"./shared/*": "./shared/*",
|
|
37
|
+
"./src/lib/mail-api.ts": "./src/lib/mail-api.ts",
|
|
38
|
+
"./src/mail/*": "./src/mail/*",
|
|
39
|
+
"./worker/backups/eml.ts": "./worker/backups/eml.ts",
|
|
40
|
+
"./worker/jmap/push.ts": "./worker/jmap/push.ts",
|
|
41
|
+
"./worker/jmap/routes.ts": "./worker/jmap/routes.ts",
|
|
42
|
+
"./worker/mail/*": "./worker/mail/*",
|
|
43
|
+
"./worker/mailbox/*": "./worker/mailbox/*"
|
|
37
44
|
},
|
|
38
45
|
"scripts": {
|
|
39
46
|
"dev": "ALLOW_MOCK_AUTH=true alchemy dev dev/alchemy.run.ts",
|
|
40
47
|
"test": "bun run test:unit && bun run test:stack",
|
|
41
|
-
"test:unit": "bun test ./test/unit",
|
|
42
|
-
"test:stack": "bun test --preload ./test/stack/setup.ts --timeout 60000 ./test/stack",
|
|
48
|
+
"test:unit": "bun test --preload @open-workspace/core/testing/workers-module ./test/unit",
|
|
49
|
+
"test:stack": "bun test --preload @open-workspace/core/testing/workers-module --preload ./test/stack/setup.ts --timeout 60000 ./test/stack",
|
|
43
50
|
"test:e2e": "playwright test -c test/e2e --project=desktop && playwright test -c test/e2e --project=mobile",
|
|
44
51
|
"typecheck": "tsc -p tsconfig.json && tsc -p test/tsconfig.json && tsc -p test/e2e/tsconfig.json",
|
|
45
52
|
"db:generate": "drizzle-kit generate && drizzle-kit generate --config=drizzle.mailbox.config.ts"
|
|
46
53
|
},
|
|
47
54
|
"dependencies": {
|
|
48
55
|
"@hono/zod-validator": "0.9.1",
|
|
56
|
+
"@hookform/resolvers": "7.0.6",
|
|
49
57
|
"@mmmike/web-push": "1.5.0",
|
|
50
58
|
"@modelcontextprotocol/server": "2.4.0",
|
|
51
59
|
"@tanstack/react-query": "5.107.1",
|
|
52
60
|
"@tiptap/extension-placeholder": "3.33.1",
|
|
61
|
+
"@tiptap/extension-table": "3.33.1",
|
|
53
62
|
"@tiptap/pm": "3.33.1",
|
|
54
63
|
"@tiptap/react": "3.33.1",
|
|
55
64
|
"@tiptap/starter-kit": "3.33.1",
|
|
@@ -59,11 +68,15 @@
|
|
|
59
68
|
"drizzle-orm": "0.45.4",
|
|
60
69
|
"hono": "4.13.17",
|
|
61
70
|
"html-to-text": "10.0.1",
|
|
71
|
+
"linkifyjs": "4.4.0",
|
|
62
72
|
"lucide-react": "1.71.0",
|
|
73
|
+
"nuqs": "2.10.3",
|
|
63
74
|
"pdfjs-dist": "6.5.438",
|
|
64
75
|
"postal-mime": "4.2.1",
|
|
65
76
|
"react": "19.3.1",
|
|
77
|
+
"react-hook-form": "7.92.0",
|
|
66
78
|
"react-router": "8.5.1",
|
|
79
|
+
"sanitize-html": "2.18.2",
|
|
67
80
|
"sonner": "2.0.8",
|
|
68
81
|
"tldts": "7.4.21",
|
|
69
82
|
"zod": "4.6.7"
|
|
@@ -73,17 +86,20 @@
|
|
|
73
86
|
"@alchemy.run/test": "2.0.0-beta.85",
|
|
74
87
|
"@effect/platform-bun": "4.1.3",
|
|
75
88
|
"@effect/platform-node": "4.1.3",
|
|
76
|
-
"@open-workspace/core": "0.
|
|
77
|
-
"@open-workspace/create": "0.
|
|
89
|
+
"@open-workspace/core": "0.5.0",
|
|
90
|
+
"@open-workspace/create": "0.5.0",
|
|
78
91
|
"@types/bun": "1.4.4",
|
|
79
92
|
"@types/html-to-text": "9.0.4",
|
|
93
|
+
"@types/jsdom": "30.0.0",
|
|
80
94
|
"@types/node": "26.6.6",
|
|
81
95
|
"@types/react": "19.3.0",
|
|
82
96
|
"@types/react-dom": "19.3.0",
|
|
97
|
+
"@types/sanitize-html": "2.16.2",
|
|
83
98
|
"ai": "7.0.166",
|
|
84
99
|
"alchemy": "2.0.0-beta.85",
|
|
85
100
|
"drizzle-kit": "0.31.11",
|
|
86
101
|
"effect": "4.1.3",
|
|
102
|
+
"jsdom": "30.1.3",
|
|
87
103
|
"openid-client": "6.8.9",
|
|
88
104
|
"playwright": "1.65.0",
|
|
89
105
|
"standardwebhooks": "1.1.1",
|
|
@@ -92,7 +108,7 @@
|
|
|
92
108
|
},
|
|
93
109
|
"peerDependencies": {
|
|
94
110
|
"@alchemy.run/cloudflare": "2.0.0-beta.85",
|
|
95
|
-
"@open-workspace/core": "0.
|
|
111
|
+
"@open-workspace/core": "0.5.0",
|
|
96
112
|
"alchemy": "2.0.0-beta.85",
|
|
97
113
|
"effect": "4.1.3"
|
|
98
114
|
}
|
|
@@ -34,16 +34,21 @@ const EXTENSION_TYPES = new Map([
|
|
|
34
34
|
["yml", "application/yaml"],
|
|
35
35
|
]);
|
|
36
36
|
|
|
37
|
+
type AttachmentPreview = {
|
|
38
|
+
kind: "pdf" | "image" | "text";
|
|
39
|
+
contentType: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
37
42
|
export function attachmentPreview(file: {
|
|
38
43
|
filename: string;
|
|
39
44
|
contentType: string;
|
|
40
45
|
pdfPreviewStatus?: PdfPreviewStatus | null;
|
|
41
|
-
})
|
|
42
|
-
kind: "pdf" | "image" | "text";
|
|
43
|
-
contentType: string;
|
|
44
|
-
} | null {
|
|
46
|
+
}) {
|
|
45
47
|
if (file.pdfPreviewStatus && officePreviewExtension(file.filename)) {
|
|
46
|
-
return {
|
|
48
|
+
return {
|
|
49
|
+
kind: "pdf",
|
|
50
|
+
contentType: "application/pdf",
|
|
51
|
+
} satisfies AttachmentPreview;
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
let contentType =
|
|
@@ -54,14 +59,16 @@ export function attachmentPreview(file: {
|
|
|
54
59
|
contentType = EXTENSION_TYPES.get(extension) ?? "";
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
if (contentType === "application/pdf")
|
|
62
|
+
if (contentType === "application/pdf") {
|
|
63
|
+
return { kind: "pdf", contentType } satisfies AttachmentPreview;
|
|
64
|
+
}
|
|
58
65
|
|
|
59
66
|
if (
|
|
60
67
|
isComposerInlineImageContentType(contentType) ||
|
|
61
68
|
contentType === "image/avif" ||
|
|
62
69
|
contentType === "image/bmp"
|
|
63
70
|
) {
|
|
64
|
-
return { kind: "image", contentType };
|
|
71
|
+
return { kind: "image", contentType } satisfies AttachmentPreview;
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
if (TEXT_TYPES.has(contentType)) {
|
|
@@ -70,7 +77,10 @@ export function attachmentPreview(file: {
|
|
|
70
77
|
"utf-8";
|
|
71
78
|
|
|
72
79
|
// XML and other structured text must never execute as same-origin documents.
|
|
73
|
-
return {
|
|
80
|
+
return {
|
|
81
|
+
kind: "text",
|
|
82
|
+
contentType: `text/plain; charset=${charset}`,
|
|
83
|
+
} satisfies AttachmentPreview;
|
|
74
84
|
}
|
|
75
85
|
|
|
76
86
|
return null;
|
package/shared/folder-order.ts
CHANGED
|
@@ -11,11 +11,12 @@ export const MOVABLE_SYSTEM_FOLDER_IDS = [
|
|
|
11
11
|
"trash",
|
|
12
12
|
] as const;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
| "inbox"
|
|
16
|
-
| (typeof MOVABLE_SYSTEM_FOLDER_IDS)[number];
|
|
14
|
+
type SystemFolderId = "inbox" | (typeof MOVABLE_SYSTEM_FOLDER_IDS)[number];
|
|
17
15
|
|
|
18
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Where the system folders sit until someone moves them. New custom folders
|
|
18
|
+
* go between Inbox and them (`insertFolder`).
|
|
19
|
+
*/
|
|
19
20
|
export const DEFAULT_SYSTEM_FOLDER_ORDER = {
|
|
20
21
|
inbox: 0,
|
|
21
22
|
sent: 10,
|
|
@@ -33,6 +34,13 @@ export function defaultSystemFolderOrder(id: string) {
|
|
|
33
34
|
return isSystemFolderId(id) ? DEFAULT_SYSTEM_FOLDER_ORDER[id] : undefined;
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Drafts: a system folder of the person's own drafts, always right after
|
|
39
|
+
* Sent. It lists the `drafts` table, not conversations, so it takes no part
|
|
40
|
+
* in the order and no folder predicate covers it.
|
|
41
|
+
*/
|
|
42
|
+
export const DRAFTS_FOLDER_ID = "drafts";
|
|
43
|
+
|
|
36
44
|
/** The gap between neighbours, so a folder created later can go after the last. */
|
|
37
45
|
export const FOLDER_ORDER_STEP = 10;
|
|
38
46
|
|
|
@@ -67,7 +75,7 @@ export function folderOrderPositions(folderIds: readonly string[]) {
|
|
|
67
75
|
type Orderable = { id: string; name: string; sortOrder: number };
|
|
68
76
|
|
|
69
77
|
/** Folders in display order: Inbox first, then by position, ties by name. */
|
|
70
|
-
export function sortFolders<T extends Orderable>(folders: readonly T[])
|
|
78
|
+
export function sortFolders<T extends Orderable>(folders: readonly T[]) {
|
|
71
79
|
return [...folders].sort(
|
|
72
80
|
(left, right) =>
|
|
73
81
|
Number(right.id === "inbox") - Number(left.id === "inbox") ||
|
|
@@ -87,7 +95,7 @@ export function moveFolderInOrder<T extends Orderable>(
|
|
|
87
95
|
) {
|
|
88
96
|
const ids = sortFolders(folders)
|
|
89
97
|
.map((folder) => folder.id)
|
|
90
|
-
.filter((id) => id !== "inbox");
|
|
98
|
+
.filter((id) => id !== "inbox" && id !== DRAFTS_FOLDER_ID);
|
|
91
99
|
|
|
92
100
|
const index = ids.indexOf(folderId);
|
|
93
101
|
const target = index + direction;
|
|
@@ -104,3 +112,20 @@ export function moveFolderInOrder<T extends Orderable>(
|
|
|
104
112
|
|
|
105
113
|
return ids;
|
|
106
114
|
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The folder a conversation is listed in, as the app names it: its custom
|
|
118
|
+
* folder or Inbox while active (Sent when it holds no received mail),
|
|
119
|
+
* else Archive, Spam or Trash. Actions name it as the folder they act in.
|
|
120
|
+
*/
|
|
121
|
+
export function conversationFolder(place: {
|
|
122
|
+
mailboxState: "active" | "archive" | "spam" | "trash";
|
|
123
|
+
folderId: string | null;
|
|
124
|
+
hasIncoming?: boolean;
|
|
125
|
+
}) {
|
|
126
|
+
if (place.mailboxState !== "active") return place.mailboxState;
|
|
127
|
+
|
|
128
|
+
if (place.hasIncoming === false) return "sent";
|
|
129
|
+
|
|
130
|
+
return place.folderId ?? "inbox";
|
|
131
|
+
}
|
package/shared/mail-headers.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type HeaderField = {
|
|
|
13
13
|
value: string;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
function headerBlock(raw: string) {
|
|
17
17
|
const separator = /\r?\n\r?\n/u.exec(raw);
|
|
18
18
|
const end = separator?.index ?? raw.length;
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@ export function headerBlock(raw: string) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/** Header fields of the top-level entity, in their original (topmost first) order. */
|
|
24
|
-
export function headerFields(raw: string)
|
|
24
|
+
export function headerFields(raw: string) {
|
|
25
25
|
const unfolded = headerBlock(raw).replaceAll(/\r?\n[\t ]+/gu, " ");
|
|
26
26
|
|
|
27
27
|
return unfolded.split(/\r?\n/gu).flatMap((line) => {
|
|
@@ -55,7 +55,7 @@ export type CommentScan = {
|
|
|
55
55
|
* Removes RFC 5322 comments (which may nest and contain quoted pairs) while
|
|
56
56
|
* leaving quoted strings intact.
|
|
57
57
|
*/
|
|
58
|
-
export function scanComments(value: string)
|
|
58
|
+
export function scanComments(value: string) {
|
|
59
59
|
let text = "";
|
|
60
60
|
let comment = "";
|
|
61
61
|
const comments: string[] = [];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function escapeHtml(value: string) {
|
|
2
|
+
return value
|
|
3
|
+
.replaceAll("&", "&")
|
|
4
|
+
.replaceAll("<", "<")
|
|
5
|
+
.replaceAll(">", ">")
|
|
6
|
+
.replaceAll('"', """)
|
|
7
|
+
.replaceAll("'", "'");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** The HTML appended to a composed reply for a new recipient. */
|
|
11
|
+
export function quotedContextHtml(quote: string | null) {
|
|
12
|
+
return quote
|
|
13
|
+
? `<blockquote><pre style="white-space:pre-wrap">${escapeHtml(quote)}</pre></blockquote>`
|
|
14
|
+
: "";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function safeLink(value: string) {
|
|
18
|
+
try {
|
|
19
|
+
const url = new URL(value);
|
|
20
|
+
|
|
21
|
+
return ["http:", "https:", "mailto:"].includes(url.protocol);
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
package/shared/mail-import.ts
CHANGED
|
@@ -29,10 +29,3 @@ export type ImportPlacement = (typeof importPlacements)[number];
|
|
|
29
29
|
|
|
30
30
|
/** The longest caller-supplied source id and thread key. */
|
|
31
31
|
export const MAX_IMPORT_KEY_LENGTH = 512;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Text bodies live in the mailbox's SQLite rows (HTML and attachments in
|
|
35
|
-
* R2), and a row must stay well under the Durable Object's row limit; an
|
|
36
|
-
* imported plain-text body beyond this is cut (the raw message keeps all of it).
|
|
37
|
-
*/
|
|
38
|
-
export const MAX_IMPORTED_TEXT_CHARACTERS = 200_000;
|
package/shared/mail-received.ts
CHANGED
|
@@ -123,7 +123,7 @@ function routeClauses(route: string) {
|
|
|
123
123
|
|
|
124
124
|
// --- IP addresses ---------------------------------------------------------
|
|
125
125
|
|
|
126
|
-
function ipv4Octets(value: string)
|
|
126
|
+
function ipv4Octets(value: string) {
|
|
127
127
|
const parts = value.split(".");
|
|
128
128
|
|
|
129
129
|
if (
|
|
@@ -319,7 +319,7 @@ function tlsDetails(value: string) {
|
|
|
319
319
|
|
|
320
320
|
type ParsedHop = Omit<ReceivedHop, "delayMs" | "skewMs" | "trusted">;
|
|
321
321
|
|
|
322
|
-
export function parseReceived(value: string)
|
|
322
|
+
export function parseReceived(value: string) {
|
|
323
323
|
const segments = splitTopLevel(value, ";");
|
|
324
324
|
let route: string;
|
|
325
325
|
let at: Date | null = null;
|
|
@@ -373,7 +373,7 @@ export function isCloudflareHop(hop: Pick<ParsedHop, "by">) {
|
|
|
373
373
|
const MAX_SKEW_MS = 10 * 60_000;
|
|
374
374
|
|
|
375
375
|
/** Received headers in delivery order: the sender's first relay first. */
|
|
376
|
-
export function receivedHops(raw: string)
|
|
376
|
+
export function receivedHops(raw: string) {
|
|
377
377
|
const values = headerFields(raw).flatMap((field) =>
|
|
378
378
|
field.name === "received" ? [field.value] : []
|
|
379
379
|
);
|
|
@@ -415,7 +415,7 @@ export function receivedHops(raw: string): ReceivedHop[] {
|
|
|
415
415
|
export type IpKind = "public" | "private" | "loopback" | "reserved";
|
|
416
416
|
|
|
417
417
|
/** Rough classification; enough to tell an internal hop from the internet. */
|
|
418
|
-
export function ipKind(ip: string)
|
|
418
|
+
export function ipKind(ip: string) {
|
|
419
419
|
const lower = ip.toLowerCase();
|
|
420
420
|
|
|
421
421
|
if (lower === "::1" || lower.startsWith("127.")) return "loopback";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const ruleActionSchema = z.discriminatedUnion("type", [
|
|
4
|
+
z.object({
|
|
5
|
+
type: z.literal("moveToFolder"),
|
|
6
|
+
folderId: z.string().min(1).max(200),
|
|
7
|
+
}),
|
|
8
|
+
z.object({ type: z.literal("archive") }),
|
|
9
|
+
z.object({ type: z.literal("trash") }),
|
|
10
|
+
z.object({ type: z.literal("spam") }),
|
|
11
|
+
z.object({ type: z.literal("notSpam") }),
|
|
12
|
+
z.object({ type: z.literal("markRead") }),
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
export type RuleAction = z.infer<typeof ruleActionSchema>;
|
|
16
|
+
|
|
17
|
+
function isDestination(type: RuleAction["type"]) {
|
|
18
|
+
return (
|
|
19
|
+
type === "moveToFolder" ||
|
|
20
|
+
type === "archive" ||
|
|
21
|
+
type === "trash" ||
|
|
22
|
+
type === "spam"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function ruleActionConflict(
|
|
27
|
+
type: RuleAction["type"],
|
|
28
|
+
others: readonly RuleAction[]
|
|
29
|
+
) {
|
|
30
|
+
if (others.some((action) => action.type === type)) {
|
|
31
|
+
return "Each action can appear once";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (
|
|
35
|
+
isDestination(type) &&
|
|
36
|
+
others.some((action) => isDestination(action.type))
|
|
37
|
+
) {
|
|
38
|
+
return "Choose only one destination";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (
|
|
42
|
+
(type === "spam" && others.some((action) => action.type === "notSpam")) ||
|
|
43
|
+
(type === "notSpam" && others.some((action) => action.type === "spam"))
|
|
44
|
+
) {
|
|
45
|
+
return "Choose only one spam action";
|
|
46
|
+
}
|
|
47
|
+
}
|
package/shared/mail.ts
CHANGED
|
@@ -7,6 +7,13 @@ export const mailboxStates = ["active", "archive", "spam", "trash"] as const;
|
|
|
7
7
|
|
|
8
8
|
export type MailboxState = (typeof mailboxStates)[number];
|
|
9
9
|
|
|
10
|
+
/** Who outside the workspace an auto-reply answers: anyone, or only people the mailbox has written to. */
|
|
11
|
+
export const autoReplyAudiences = ["everyone", "knownSenders"] as const;
|
|
12
|
+
|
|
13
|
+
export type AutoReplyAudience = (typeof autoReplyAudiences)[number];
|
|
14
|
+
|
|
15
|
+
export type AutoReplyStatus = "off" | "scheduled" | "active" | "ended";
|
|
16
|
+
|
|
10
17
|
export const transportStates = [
|
|
11
18
|
"received",
|
|
12
19
|
"unconfirmed",
|
|
@@ -30,6 +37,7 @@ export type ReplyAction = {
|
|
|
30
37
|
label: string;
|
|
31
38
|
to: string[];
|
|
32
39
|
cc: string[];
|
|
40
|
+
bcc?: string[];
|
|
33
41
|
};
|
|
34
42
|
|
|
35
43
|
export type ReplyPlan = {
|
|
@@ -94,7 +102,6 @@ export type MailboxRealtimeClientMessage = "visible" | "hidden";
|
|
|
94
102
|
|
|
95
103
|
type MailboxPushJobBase = {
|
|
96
104
|
mailboxId: string;
|
|
97
|
-
conversationId: string;
|
|
98
105
|
messageId: string;
|
|
99
106
|
occurredAt: number;
|
|
100
107
|
sender: string;
|
|
@@ -116,9 +123,34 @@ export type MailboxPushJob =
|
|
|
116
123
|
type: "jmap-state";
|
|
117
124
|
mailboxId: string;
|
|
118
125
|
state: string;
|
|
126
|
+
/** New mail arrived: JMAP's EmailDelivery moves too. */
|
|
127
|
+
delivered: boolean;
|
|
119
128
|
occurredAt: number;
|
|
120
129
|
};
|
|
121
130
|
|
|
131
|
+
// The text, sent HTML and editable HTML are stored together in one draft row.
|
|
132
|
+
export const MAX_COMPOSER_TEXT_LENGTH = 150_000;
|
|
133
|
+
export const MAX_COMPOSER_HTML_LENGTH = 200_000;
|
|
134
|
+
|
|
135
|
+
export function composerBodyLimitError(body: {
|
|
136
|
+
bodyText?: string;
|
|
137
|
+
bodyHtml?: string | null;
|
|
138
|
+
editorHtml?: string | null;
|
|
139
|
+
}) {
|
|
140
|
+
if ((body.bodyText?.length ?? 0) > MAX_COMPOSER_TEXT_LENGTH) {
|
|
141
|
+
return `Shorten the message to ${MAX_COMPOSER_TEXT_LENGTH.toLocaleString("en-US")} characters to save or send it.`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (
|
|
145
|
+
Math.max(body.bodyHtml?.length ?? 0, body.editorHtml?.length ?? 0) >
|
|
146
|
+
MAX_COMPOSER_HTML_LENGTH
|
|
147
|
+
) {
|
|
148
|
+
return "Shorten the message or remove some formatting to save or send it.";
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
122
154
|
export const MAX_COMPOSER_ATTACHMENT_BYTES = 500_000_000;
|
|
123
155
|
export const MAX_COMPOSER_ATTACHMENT_COUNT = 10;
|
|
124
156
|
export const MAX_BULK_CONVERSATION_COUNT = 500;
|
|
@@ -165,6 +197,8 @@ export function composerAttachmentLimitError(
|
|
|
165
197
|
return null;
|
|
166
198
|
}
|
|
167
199
|
|
|
200
|
+
export class EmailSizeLimitError extends Error {}
|
|
201
|
+
|
|
168
202
|
type ComposerAttachmentSize = {
|
|
169
203
|
id: string;
|
|
170
204
|
size: number;
|
|
@@ -194,9 +228,17 @@ export function attachmentsRequiringDownloadLinks(input: {
|
|
|
194
228
|
byteLength(input.bodyText) +
|
|
195
229
|
byteLength(input.bodyHtml);
|
|
196
230
|
|
|
231
|
+
const estimatedBodySize =
|
|
232
|
+
MIME_FIXED_OVERHEAD_BYTES + base64EncodedSize(bodyBytes);
|
|
233
|
+
|
|
234
|
+
if (estimatedBodySize > EMAIL_SERVICE_MAX_BYTES) {
|
|
235
|
+
throw new EmailSizeLimitError(
|
|
236
|
+
`This message is estimated to exceed the ${EMAIL_SERVICE_MAX_BYTES / 1024 / 1024} MiB sending limit. Shorten its text before sending.`
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
197
240
|
let estimatedBytes =
|
|
198
|
-
|
|
199
|
-
base64EncodedSize(bodyBytes) +
|
|
241
|
+
estimatedBodySize +
|
|
200
242
|
input.attachments.reduce(
|
|
201
243
|
(total, attachment) => total + base64EncodedSize(attachment.size) + 2048,
|
|
202
244
|
0
|
|
@@ -218,8 +260,16 @@ export function attachmentsRequiringDownloadLinks(input: {
|
|
|
218
260
|
return linked;
|
|
219
261
|
}
|
|
220
262
|
|
|
263
|
+
/**
|
|
264
|
+
* The subject without reply and forward prefixes, however many: `Re:`,
|
|
265
|
+
* `RE :`, `Re[2]:`, `Fwd:`, `Fw:`, and the German and Scandinavian
|
|
266
|
+
* `AW:`, `WG:`, `SV:`.
|
|
267
|
+
*/
|
|
221
268
|
export function baseSubject(subject: string) {
|
|
222
|
-
return subject.
|
|
269
|
+
return subject.replace(
|
|
270
|
+
/^\s*(?:(?:re|fwd?|aw|wg|sv)(?:\[\d+\]|\(\d+\))?\s*:\s*)+/iu,
|
|
271
|
+
""
|
|
272
|
+
);
|
|
223
273
|
}
|
|
224
274
|
|
|
225
275
|
export function replySubject(subject: string) {
|
|
@@ -229,3 +279,19 @@ export function replySubject(subject: string) {
|
|
|
229
279
|
export function forwardSubject(subject: string) {
|
|
230
280
|
return `Fwd: ${baseSubject(subject)}`;
|
|
231
281
|
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Where a conversation's mail is after an action on it: `from`, the
|
|
285
|
+
* conversation it was in; `conversationId` and `folder`, where it is now
|
|
286
|
+
* (a conversation of its own in Spam, or the thread it rejoined; no folder
|
|
287
|
+
* once deleted); `left`, whether `from` is no longer listed where it was.
|
|
288
|
+
* Every action on conversations answers with these.
|
|
289
|
+
*/
|
|
290
|
+
export type ConversationPlace = {
|
|
291
|
+
/** Filing to restore on Undo. Sent-only conversations have no Inbox folder to assign. */
|
|
292
|
+
previous?: { mailboxState: MailboxState; folderId?: string | null };
|
|
293
|
+
from: string;
|
|
294
|
+
conversationId: string;
|
|
295
|
+
folder: string | null;
|
|
296
|
+
left: boolean;
|
|
297
|
+
};
|
package/shared/office-preview.ts
CHANGED
|
@@ -24,10 +24,6 @@ export function officePreviewExtension(filename: string) {
|
|
|
24
24
|
return extension && OFFICE_EXTENSIONS.has(extension) ? extension : null;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function officePreviewKey(sourceKey: string) {
|
|
28
|
-
return `${sourceKey}.preview.pdf`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
27
|
export type OfficePreviewJob = {
|
|
32
28
|
mailboxId: string;
|
|
33
29
|
messageId: string;
|
package/shared/pdfjs-assets.ts
CHANGED
|
@@ -20,9 +20,7 @@ export function pdfjsAssetPath(version: string, folder: PdfjsAssetFolder) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/** `getDocument`'s options that point PDF.js at its resources. */
|
|
23
|
-
export function pdfjsAssetUrls(
|
|
24
|
-
version: string
|
|
25
|
-
): Record<keyof typeof pdfjsAssetFolders, string> {
|
|
23
|
+
export function pdfjsAssetUrls(version: string) {
|
|
26
24
|
const url = (folder: PdfjsAssetFolder) =>
|
|
27
25
|
`/${pdfjsAssetPath(version, folder)}/`;
|
|
28
26
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich content saved for later sending, such as a signature: HTML from the
|
|
3
|
+
* composer's editor whose images are `cid:` references to objects in R2,
|
|
4
|
+
* kept under an owner prefix for as long as the content exists.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** A signature or auto-reply image goes out with every message. */
|
|
8
|
+
export const MAX_RICH_IMAGE_BYTES = 1_000_000;
|
|
9
|
+
|
|
10
|
+
/** An image of saved rich content, sent inline under its content id. */
|
|
11
|
+
export type RichImage = {
|
|
12
|
+
contentId: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
contentType: string;
|
|
15
|
+
size: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** A reference, in a composed message, to an image of saved rich content. */
|
|
19
|
+
export type StoredImageRef = { ownerId: string; contentId: string };
|
|
20
|
+
|
|
21
|
+
export function normalizedContentId(value: string) {
|
|
22
|
+
let decoded = value;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
decoded = decodeURIComponent(value);
|
|
26
|
+
} catch {
|
|
27
|
+
// Malformed percent escapes are treated as an opaque content ID.
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return decoded
|
|
31
|
+
.replace(/^cid:/iu, "")
|
|
32
|
+
.replaceAll(/^<|>$/gu, "")
|
|
33
|
+
.trim()
|
|
34
|
+
.toLocaleLowerCase();
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A signature's HTML with `{name}` replaced by the sender's display name,
|
|
3
|
+
* escaped, so a team inbox's replies all read alike. The composer fills it in
|
|
4
|
+
* when it inserts a signature; the Worker when an API caller asks for one.
|
|
5
|
+
*/
|
|
6
|
+
export function signatureHtmlWithName(html: string, name: string) {
|
|
7
|
+
const escaped = name
|
|
8
|
+
.replaceAll("&", "&")
|
|
9
|
+
.replaceAll("<", "<")
|
|
10
|
+
.replaceAll(">", ">")
|
|
11
|
+
.replaceAll('"', """)
|
|
12
|
+
.replaceAll("'", "'");
|
|
13
|
+
|
|
14
|
+
return html.replaceAll("{name}", escaped);
|
|
15
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { TeamAddress, UserAddress } from "@open-workspace/core/ui";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
|
|
4
|
+
import { mailboxesQuery } from "../mail/mail-queries";
|
|
5
|
+
import { MailboxAutoReply } from "../settings/auto-reply-editor";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* An address's auto-reply, in its editor under Administration → Teams or
|
|
9
|
+
* People, saved with "Save address". Only an address with its own mailbox
|
|
10
|
+
* has one: an alias is answered by its target's, and a mailing list's mail
|
|
11
|
+
* goes straight to its members. It follows the delivery chosen in the form.
|
|
12
|
+
*/
|
|
13
|
+
export function AddressAutoReply({
|
|
14
|
+
address,
|
|
15
|
+
}: {
|
|
16
|
+
address: TeamAddress | UserAddress;
|
|
17
|
+
}) {
|
|
18
|
+
return address.delivery === "inbox" ? (
|
|
19
|
+
<AddressAutoReplySection address={address} />
|
|
20
|
+
) : null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function AddressAutoReplySection({
|
|
24
|
+
address,
|
|
25
|
+
}: {
|
|
26
|
+
address: TeamAddress | UserAddress;
|
|
27
|
+
}) {
|
|
28
|
+
const mailboxes = useQuery(mailboxesQuery());
|
|
29
|
+
|
|
30
|
+
// Images upload through a mailbox the administrator can send from.
|
|
31
|
+
const sendable = mailboxes.data?.mailboxes.filter(
|
|
32
|
+
(mailbox) => mailbox.canSend
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const uploadMailbox =
|
|
36
|
+
sendable?.find((mailbox) => mailbox.id === address.mailboxId) ??
|
|
37
|
+
sendable?.[0];
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className="space-y-2">
|
|
41
|
+
<h3 className="text-sm leading-none font-medium">Auto-reply</h3>
|
|
42
|
+
<MailboxAutoReply
|
|
43
|
+
mailbox={{ id: address.mailboxId, address: address.address }}
|
|
44
|
+
uploadMailboxId={uploadMailbox?.id}
|
|
45
|
+
section
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|