@rapidmx/web-client 0.16.0 → 0.17.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 +36 -28
- package/apps/admin/distribution-lists/new/index.tsx +3 -1
- package/apps/admin/domains/[uid].tsx +3 -1
- package/apps/admin/domains/new/index.tsx +3 -1
- package/apps/admin/escrow-scopes/[uid].tsx +3 -1
- package/apps/admin/escrow-scopes/new/index.tsx +3 -1
- package/apps/admin/index.tsx +3 -1
- package/apps/admin/mailboxes/[uid].tsx +3 -1
- package/apps/admin/mailboxes/new/index.tsx +3 -1
- package/apps/admin/transport-rules/new/index.tsx +3 -1
- package/apps/escrow/matters/new/index.tsx +3 -1
- package/apps/shared/components/admin/layout/AdminShell.tsx +4 -1
- package/apps/shared/components/admin/setup/SetupWizard.tsx +3 -1
- package/apps/shared/components/calendar/layout/CalendarShell.tsx +2 -2
- package/apps/shared/components/contacts/layout/ContactsShell.tsx +3 -2
- package/apps/shared/components/layout/AppShell.tsx +24 -43
- package/apps/shared/components/mail/ConversationThreadPane.tsx +1 -0
- package/apps/shared/components/mail/EmptyFolderBar.tsx +41 -0
- package/apps/shared/components/mail/MailSelectionBar.tsx +19 -15
- package/apps/shared/components/mail/MenuButton.tsx +31 -11
- package/apps/shared/components/mail/MessageDetailPane.tsx +202 -4
- package/apps/shared/components/mail/PermanentDeleteDialog.tsx +47 -0
- package/apps/shared/components/mail/layout/MailShell.tsx +37 -34
- package/apps/shared/components/mail/reading/MessageMoreMenu.tsx +258 -0
- package/apps/shared/components/mail/reading/MessageSourceDialog.tsx +79 -0
- package/apps/shared/components/mail/reading/messageExport.ts +59 -0
- package/apps/shared/components/mail/reading/printMessage.ts +99 -0
- package/apps/shared/components/mail/reading/useMessageActions.ts +443 -0
- package/apps/shared/components/settings/layout/SettingsShell.tsx +4 -2
- package/apps/shared/components/tasks/layout/TasksShell.tsx +3 -2
- package/apps/shared/keyboard/GlobalShortcuts.tsx +1 -1
- package/apps/shared/mail/folderOfType.ts +49 -0
- package/apps/shared/mail/permanentDelete.ts +160 -0
- package/apps/shared/mail/reportNotices.ts +66 -0
- package/apps/shared/mail/senderBlocking.ts +141 -0
- package/apps/shared/mail/useMailboxUpdateAccess.ts +60 -0
- package/apps/shared/mail/usePermanentDelete.tsx +160 -0
- package/apps/shared/navigation/frameContext.tsx +1 -1
- package/apps/shared/navigation/index.ts +43 -0
- package/apps/shared/navigation/pageTitle.ts +19 -0
- package/apps/www/_shell.tsx +82 -0
- package/apps/www/calendar/index.tsx +5 -2
- package/apps/www/contacts/[uid].tsx +6 -3
- package/apps/www/contacts/index.tsx +8 -3
- package/apps/www/index.tsx +146 -31
- package/apps/www/messages/[uid].tsx +8 -4
- package/apps/www/settings/appearance/index.tsx +5 -2
- package/apps/www/settings/auto-reply/index.tsx +5 -2
- package/apps/www/settings/blocked-senders/index.tsx +303 -0
- package/apps/www/settings/encryption/index.tsx +5 -2
- package/apps/www/settings/filters/[uid].tsx +5 -2
- package/apps/www/settings/filters/index.tsx +5 -2
- package/apps/www/settings/filters/new/index.tsx +30 -5
- package/apps/www/settings/labels/index.tsx +5 -2
- package/apps/www/settings/privacy/index.tsx +5 -2
- package/apps/www/settings/profile/index.tsx +5 -2
- package/apps/www/settings/read-receipts/index.tsx +5 -2
- package/apps/www/settings/sharing/index.tsx +5 -2
- package/apps/www/settings/signatures/[uid].tsx +5 -2
- package/apps/www/settings/signatures/index.tsx +5 -2
- package/apps/www/settings/signatures/new/index.tsx +6 -3
- package/apps/www/tasks/index.tsx +7 -2
- package/dist/apps/admin/distribution-lists/new/index.js +3 -1
- package/dist/apps/admin/domains/[uid].js +3 -1
- package/dist/apps/admin/domains/new/index.js +3 -1
- package/dist/apps/admin/escrow-scopes/[uid].js +3 -1
- package/dist/apps/admin/escrow-scopes/new/index.js +3 -1
- package/dist/apps/admin/index.js +3 -1
- package/dist/apps/admin/mailboxes/[uid].js +3 -1
- package/dist/apps/admin/mailboxes/new/index.js +3 -1
- package/dist/apps/admin/transport-rules/new/index.js +3 -1
- package/dist/apps/escrow/matters/new/index.js +3 -1
- package/dist/apps/shared/components/admin/layout/AdminShell.js +4 -1
- package/dist/apps/shared/components/admin/setup/SetupWizard.js +3 -1
- package/dist/apps/shared/components/calendar/layout/CalendarShell.js +2 -2
- package/dist/apps/shared/components/contacts/layout/ContactsShell.js +3 -2
- package/dist/apps/shared/components/layout/AppShell.d.ts +8 -11
- package/dist/apps/shared/components/layout/AppShell.js +24 -33
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +1 -1
- package/dist/apps/shared/components/mail/EmptyFolderBar.d.ts +18 -0
- package/dist/apps/shared/components/mail/EmptyFolderBar.js +10 -0
- package/dist/apps/shared/components/mail/MailSelectionBar.d.ts +9 -4
- package/dist/apps/shared/components/mail/MailSelectionBar.js +10 -12
- package/dist/apps/shared/components/mail/MenuButton.d.ts +9 -2
- package/dist/apps/shared/components/mail/MenuButton.js +15 -11
- package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +5 -0
- package/dist/apps/shared/components/mail/MessageDetailPane.js +147 -7
- package/dist/apps/shared/components/mail/PermanentDeleteDialog.d.ts +19 -0
- package/dist/apps/shared/components/mail/PermanentDeleteDialog.js +11 -0
- package/dist/apps/shared/components/mail/layout/MailShell.d.ts +13 -9
- package/dist/apps/shared/components/mail/layout/MailShell.js +27 -33
- package/dist/apps/shared/components/mail/reading/MessageMoreMenu.d.ts +56 -0
- package/dist/apps/shared/components/mail/reading/MessageMoreMenu.js +153 -0
- package/dist/apps/shared/components/mail/reading/MessageSourceDialog.d.ts +27 -0
- package/dist/apps/shared/components/mail/reading/MessageSourceDialog.js +27 -0
- package/dist/apps/shared/components/mail/reading/messageExport.d.ts +19 -0
- package/dist/apps/shared/components/mail/reading/messageExport.js +51 -0
- package/dist/apps/shared/components/mail/reading/printMessage.d.ts +30 -0
- package/dist/apps/shared/components/mail/reading/printMessage.js +70 -0
- package/dist/apps/shared/components/mail/reading/useMessageActions.d.ts +57 -0
- package/dist/apps/shared/components/mail/reading/useMessageActions.js +366 -0
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +4 -2
- package/dist/apps/shared/components/tasks/layout/TasksShell.js +3 -2
- package/dist/apps/shared/keyboard/GlobalShortcuts.js +1 -1
- package/dist/apps/shared/mail/folderOfType.d.ts +13 -0
- package/dist/apps/shared/mail/folderOfType.js +40 -0
- package/dist/apps/shared/mail/permanentDelete.d.ts +62 -0
- package/dist/apps/shared/mail/permanentDelete.js +127 -0
- package/dist/apps/shared/mail/reportNotices.d.ts +21 -0
- package/dist/apps/shared/mail/reportNotices.js +47 -0
- package/dist/apps/shared/mail/senderBlocking.d.ts +26 -0
- package/dist/apps/shared/mail/senderBlocking.js +92 -0
- package/dist/apps/shared/mail/useMailboxUpdateAccess.d.ts +11 -0
- package/dist/apps/shared/mail/useMailboxUpdateAccess.js +52 -0
- package/dist/apps/shared/mail/usePermanentDelete.d.ts +35 -0
- package/dist/apps/shared/mail/usePermanentDelete.js +96 -0
- package/dist/apps/shared/navigation/frameContext.d.ts +1 -1
- package/dist/apps/shared/navigation/index.d.ts +16 -0
- package/dist/apps/shared/navigation/index.js +34 -0
- package/dist/apps/shared/navigation/pageTitle.d.ts +11 -0
- package/dist/apps/shared/navigation/pageTitle.js +12 -0
- package/dist/apps/www/_shell.d.ts +26 -0
- package/dist/apps/www/_shell.js +31 -0
- package/dist/apps/www/calendar/index.d.ts +7 -2
- package/dist/apps/www/calendar/index.js +4 -2
- package/dist/apps/www/contacts/[uid].d.ts +14 -3
- package/dist/apps/www/contacts/[uid].js +5 -3
- package/dist/apps/www/contacts/index.d.ts +7 -2
- package/dist/apps/www/contacts/index.js +6 -4
- package/dist/apps/www/index.d.ts +7 -2
- package/dist/apps/www/index.js +117 -19
- package/dist/apps/www/messages/[uid].d.ts +14 -3
- package/dist/apps/www/messages/[uid].js +7 -5
- package/dist/apps/www/settings/appearance/index.d.ts +8 -2
- package/dist/apps/www/settings/appearance/index.js +4 -2
- package/dist/apps/www/settings/auto-reply/index.d.ts +7 -2
- package/dist/apps/www/settings/auto-reply/index.js +4 -2
- package/dist/apps/www/settings/blocked-senders/index.d.ts +9 -0
- package/dist/apps/www/settings/blocked-senders/index.js +134 -0
- package/dist/apps/www/settings/encryption/index.d.ts +7 -2
- package/dist/apps/www/settings/encryption/index.js +4 -2
- package/dist/apps/www/settings/filters/[uid].d.ts +7 -2
- package/dist/apps/www/settings/filters/[uid].js +4 -2
- package/dist/apps/www/settings/filters/index.d.ts +7 -2
- package/dist/apps/www/settings/filters/index.js +4 -2
- package/dist/apps/www/settings/filters/new/index.d.ts +7 -2
- package/dist/apps/www/settings/filters/new/index.js +28 -5
- package/dist/apps/www/settings/labels/index.d.ts +7 -2
- package/dist/apps/www/settings/labels/index.js +4 -2
- package/dist/apps/www/settings/privacy/index.d.ts +7 -2
- package/dist/apps/www/settings/privacy/index.js +4 -2
- package/dist/apps/www/settings/profile/index.d.ts +7 -2
- package/dist/apps/www/settings/profile/index.js +4 -2
- package/dist/apps/www/settings/read-receipts/index.d.ts +7 -2
- package/dist/apps/www/settings/read-receipts/index.js +4 -2
- package/dist/apps/www/settings/sharing/index.d.ts +7 -2
- package/dist/apps/www/settings/sharing/index.js +4 -2
- package/dist/apps/www/settings/signatures/[uid].d.ts +7 -2
- package/dist/apps/www/settings/signatures/[uid].js +4 -2
- package/dist/apps/www/settings/signatures/index.d.ts +7 -2
- package/dist/apps/www/settings/signatures/index.js +4 -2
- package/dist/apps/www/settings/signatures/new/index.d.ts +7 -2
- package/dist/apps/www/settings/signatures/new/index.js +5 -3
- package/dist/apps/www/tasks/index.d.ts +7 -2
- package/dist/apps/www/tasks/index.js +5 -3
- package/package.json +4 -2
- package/apps/shared/navigation/AppRouter.tsx +0 -300
- package/apps/shared/navigation/idle.ts +0 -45
- package/apps/shared/navigation/routerContext.tsx +0 -83
- package/apps/shared/navigation/routes.ts +0 -72
- package/apps/www/_routedPage.tsx +0 -24
- package/apps/www/_routes.ts +0 -37
- package/dist/apps/shared/navigation/AppRouter.d.ts +0 -52
- package/dist/apps/shared/navigation/AppRouter.js +0 -242
- package/dist/apps/shared/navigation/idle.d.ts +0 -14
- package/dist/apps/shared/navigation/idle.js +0 -43
- package/dist/apps/shared/navigation/routerContext.d.ts +0 -37
- package/dist/apps/shared/navigation/routerContext.js +0 -56
- package/dist/apps/shared/navigation/routes.d.ts +0 -32
- package/dist/apps/shared/navigation/routes.js +0 -37
- package/dist/apps/www/_routedPage.d.ts +0 -12
- package/dist/apps/www/_routedPage.js +0 -19
- package/dist/apps/www/_routes.d.ts +0 -11
- package/dist/apps/www/_routes.js +0 -31
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import { Folder, Message } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
3
|
+
import type { CountTracker } from "../../../mail/folderCounts.js";
|
|
4
|
+
export interface MessageActionsParams {
|
|
5
|
+
/** The message the card shows, and the newest copy of it known (a version another action of the card has since raised). */
|
|
6
|
+
message: Message;
|
|
7
|
+
newest: () => Message;
|
|
8
|
+
/** Records a newer copy, so the next action builds on its `version`. */
|
|
9
|
+
remember: (updated: Message) => void;
|
|
10
|
+
/** Every folder of the message's mailbox - `resolveFolderOfType()` finds Junk Email, Deleted Items and the Inbox among them. */
|
|
11
|
+
folders: Folder[] | undefined;
|
|
12
|
+
inJunk: boolean;
|
|
13
|
+
/** The message is in its mailbox's Deleted Items: Delete is then the permanent one (asked first, see `usePermanentDelete()`). */
|
|
14
|
+
inDeletedItems: boolean;
|
|
15
|
+
/** Every address the reader owns (their mailboxes' primary addresses and aliases), lowercase: a sender among them is never blocked. */
|
|
16
|
+
ownAddresses?: readonly string[];
|
|
17
|
+
trackMessageChange: (previous: Message, next: Message | null) => CountTracker;
|
|
18
|
+
/** The message left the folder it was in (Delete, Report junk, Block): the caller takes it out of its list, or the thread. */
|
|
19
|
+
onMoved?: (updated: Message) => void;
|
|
20
|
+
/** A newer copy of the message that is still where it was (read, flagged), with the copy it replaces. */
|
|
21
|
+
onChanged?: (updated: Message, previous?: Message) => void;
|
|
22
|
+
onFolderCreated?: (folder: Folder) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface MessageActions {
|
|
25
|
+
/** An action is on the wire: the card's other actions wait for it. */
|
|
26
|
+
busy: boolean;
|
|
27
|
+
/** The permanent-delete confirmation - render it once (it is a portal). */
|
|
28
|
+
dialog: ReactElement;
|
|
29
|
+
reportJunk: () => Promise<void>;
|
|
30
|
+
reportPhishing: () => Promise<void>;
|
|
31
|
+
/** Not junk: to the Inbox, and the spam filter is told the message is legitimate. */
|
|
32
|
+
notJunk: () => Promise<void>;
|
|
33
|
+
/** Not junk, and the sender is added to the mailbox's Safe Senders (needs full access to the mailbox). */
|
|
34
|
+
notJunkAndTrust: () => Promise<void>;
|
|
35
|
+
deleteMessage: () => Promise<void>;
|
|
36
|
+
toggleRead: () => Promise<void>;
|
|
37
|
+
toggleFlag: () => Promise<void>;
|
|
38
|
+
blockSender: () => Promise<void>;
|
|
39
|
+
neverBlockSender: () => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/** Where a notification's "View rules" goes: the filters page of the mailbox. */
|
|
42
|
+
export declare function rulesHref(mailboxUid: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* What a message card's Report junk, Report phishing, Not junk, Delete, Mark as read/unread, Flag, Block and Never block do.
|
|
45
|
+
*
|
|
46
|
+
* - **Report junk, phishing and Not junk** ask the SERVER to do it (`reportMessage()`): it moves the message, teaches its spam filter and audits the report,
|
|
47
|
+
* and the card then does what a move did (the folder badges, the search index, taking the message out of its list). A server that predates the route answers
|
|
48
|
+
* `404`, and the card then makes the move itself (`moveMessage()`), as it used to, so a new client still works.
|
|
49
|
+
* - **Block** adds the sender to the message's OWN mailbox's Blocked Senders (`addBlockedSender()`) and moves the message to Junk Email; **Never block** adds it to
|
|
50
|
+
* Safe Senders, which takes it off the blocked list. On a server without the lists (`404`) both fall back to mail filter rules (`senderBlocking.ts`).
|
|
51
|
+
* - The rest go over the same requests the mail page's selection bar and keyboard shortcuts make - a move is a move into the message's OWN mailbox's Junk Email or
|
|
52
|
+
* Deleted Items folder (`resolveFolderOfType()`), a read or flag change goes through the same optimistic path - so a card opened from a shared mailbox, or from a
|
|
53
|
+
* search over several, acts in the mailbox the message is in.
|
|
54
|
+
*
|
|
55
|
+
* A failure is a pop-up that says what could not be done (`notifyApiError()`), as the selection bar's are. Nothing here rejects.
|
|
56
|
+
*/
|
|
57
|
+
export declare function useMessageActions(params: MessageActionsParams): MessageActions;
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { getMessageRawContent, moveMessage, reportMessage, setMessageFlagged, } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
7
|
+
import { addBlockedSender, addSafeSender, checkSenderEntry, removeBlockedSender, removeSafeSender, } from "@rapidmx/react-shared/mail/senderListsApi.js";
|
|
8
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
9
|
+
import { resolveFolderOfType } from "../../../mail/folderOfType.js";
|
|
10
|
+
import { setReadStateMany } from "../../../mail/messageReadState.js";
|
|
11
|
+
import { usePermanentDelete } from "../../../mail/usePermanentDelete.js";
|
|
12
|
+
import { reportFolderName, reportNotice, reportNoun, reportTitle, senderListsHref } from "../../../mail/reportNotices.js";
|
|
13
|
+
import { blockSender, neverBlockSender, normalizeAddresses, removeSenderRule } from "../../../mail/senderBlocking.js";
|
|
14
|
+
import { notifyApiError } from "../../../notifications/apiErrors.js";
|
|
15
|
+
import { notify } from "../../../notifications/store.js";
|
|
16
|
+
import { moveLocalEntity } from "../../../search/localIndexRpcClient.js";
|
|
17
|
+
import { displaySubject } from "./EncryptedPreview.js";
|
|
18
|
+
import { headerFromAddress } from "./messageExport.js";
|
|
19
|
+
/** Where a notification's "View rules" goes: the filters page of the mailbox. */
|
|
20
|
+
export function rulesHref(mailboxUid) {
|
|
21
|
+
return `/settings/filters?mailboxUid=${encodeURIComponent(mailboxUid)}`;
|
|
22
|
+
}
|
|
23
|
+
/** Whether `err` is a `404`: for a route, what a server that predates it answers (a message or mailbox that is gone answers the same, and the fallback then fails the same way). */
|
|
24
|
+
function isNotFound(err) {
|
|
25
|
+
return err instanceof ApiRequestError && err.status === 404;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* What a message card's Report junk, Report phishing, Not junk, Delete, Mark as read/unread, Flag, Block and Never block do.
|
|
29
|
+
*
|
|
30
|
+
* - **Report junk, phishing and Not junk** ask the SERVER to do it (`reportMessage()`): it moves the message, teaches its spam filter and audits the report,
|
|
31
|
+
* and the card then does what a move did (the folder badges, the search index, taking the message out of its list). A server that predates the route answers
|
|
32
|
+
* `404`, and the card then makes the move itself (`moveMessage()`), as it used to, so a new client still works.
|
|
33
|
+
* - **Block** adds the sender to the message's OWN mailbox's Blocked Senders (`addBlockedSender()`) and moves the message to Junk Email; **Never block** adds it to
|
|
34
|
+
* Safe Senders, which takes it off the blocked list. On a server without the lists (`404`) both fall back to mail filter rules (`senderBlocking.ts`).
|
|
35
|
+
* - The rest go over the same requests the mail page's selection bar and keyboard shortcuts make - a move is a move into the message's OWN mailbox's Junk Email or
|
|
36
|
+
* Deleted Items folder (`resolveFolderOfType()`), a read or flag change goes through the same optimistic path - so a card opened from a shared mailbox, or from a
|
|
37
|
+
* search over several, acts in the mailbox the message is in.
|
|
38
|
+
*
|
|
39
|
+
* A failure is a pop-up that says what could not be done (`notifyApiError()`), as the selection bar's are. Nothing here rejects.
|
|
40
|
+
*/
|
|
41
|
+
export function useMessageActions(params) {
|
|
42
|
+
const { message, newest, remember, folders, inJunk, inDeletedItems, ownAddresses = [], trackMessageChange, onMoved, onChanged, onFolderCreated } = params;
|
|
43
|
+
const [busy, setBusy] = useState(false);
|
|
44
|
+
const permanent = usePermanentDelete();
|
|
45
|
+
/** Runs one action with the card's other actions held meanwhile. */
|
|
46
|
+
async function exclusive(action) {
|
|
47
|
+
setBusy(true);
|
|
48
|
+
try {
|
|
49
|
+
await action();
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
setBusy(false);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function folderOf(type, name) {
|
|
56
|
+
return resolveFolderOfType(message.mailboxUid, type, name, folders, onFolderCreated);
|
|
57
|
+
}
|
|
58
|
+
/** The card's part of a message having left its folder for `updated`'s: the folder badges and the local search index. */
|
|
59
|
+
function relocated(before, updated) {
|
|
60
|
+
remember(updated);
|
|
61
|
+
void moveLocalEntity(updated.mailboxUid, updated.uid, updated.folderUid);
|
|
62
|
+
trackMessageChange(before, updated).settle();
|
|
63
|
+
}
|
|
64
|
+
/** Moves the message into its mailbox's folder of `type`, and tells the folder badges and the local search index. */
|
|
65
|
+
async function moveToType(type, name) {
|
|
66
|
+
const before = newest();
|
|
67
|
+
const updated = await moveMessage(before, await folderOf(type, name));
|
|
68
|
+
relocated(before, updated);
|
|
69
|
+
return updated;
|
|
70
|
+
}
|
|
71
|
+
const subjectOf = () => displaySubject(message.subject) || "(no subject)";
|
|
72
|
+
/** What the server did with a report, as the card shows it: the message is out of its list (when it moved) and a pop-up says what happened. */
|
|
73
|
+
function reported(result, alwaysTrust) {
|
|
74
|
+
const before = newest();
|
|
75
|
+
if (result.folderUid !== before.folderUid) {
|
|
76
|
+
// The answer names no new `version`; the message is out of the card's list now, so nothing builds on this copy.
|
|
77
|
+
const updated = { ...before, folderUid: result.folderUid };
|
|
78
|
+
relocated(before, updated);
|
|
79
|
+
onMoved?.(updated);
|
|
80
|
+
}
|
|
81
|
+
const notice = reportNotice(result, subjectOf(), alwaysTrust);
|
|
82
|
+
const safeSender = result.safeSender;
|
|
83
|
+
notify({
|
|
84
|
+
kind: "success",
|
|
85
|
+
title: notice.title,
|
|
86
|
+
message: notice.message,
|
|
87
|
+
hint: notice.hint,
|
|
88
|
+
actions: safeSender
|
|
89
|
+
? [
|
|
90
|
+
{
|
|
91
|
+
label: "Undo",
|
|
92
|
+
onClick: () => {
|
|
93
|
+
removeSafeSender(message.mailboxUid, safeSender).then(() => notify({ kind: "info", title: `${safeSender} is no longer a safe sender`, message: "This message stays in the Inbox." }), (err) => notifyApiError(err, "Couldn't undo trusting this sender"));
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{ label: "Manage safe senders", href: senderListsHref(message.mailboxUid) },
|
|
97
|
+
]
|
|
98
|
+
: undefined,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** What a server that has no report route leaves: the move alone, in the message's own mailbox, and nothing learned. */
|
|
102
|
+
async function reportByMoving(kind, alwaysTrust) {
|
|
103
|
+
const toInbox = kind === "not_junk";
|
|
104
|
+
let updated;
|
|
105
|
+
try {
|
|
106
|
+
updated = await moveToType(toInbox ? "inbox" : "junk", toInbox ? "Inbox" : "Junk Email");
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
notifyApiError(err, `Couldn't report this message as ${reportNoun(kind)}`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
onMoved?.(updated);
|
|
113
|
+
notify({
|
|
114
|
+
kind: "success",
|
|
115
|
+
title: reportTitle(kind),
|
|
116
|
+
message: `“${subjectOf()}” was moved to ${reportFolderName(kind)}.${alwaysTrust ? " This server cannot keep a list of safe senders, so its sender was not added to one." : ""}`,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async function report(kind, alwaysTrustSender = false) {
|
|
120
|
+
await exclusive(async () => {
|
|
121
|
+
let result;
|
|
122
|
+
try {
|
|
123
|
+
result = await reportMessage(message.uid, kind, { alwaysTrustSender });
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
if (isNotFound(err)) {
|
|
127
|
+
await reportByMoving(kind, alwaysTrustSender);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
notifyApiError(err, `Couldn't report this message as ${reportNoun(kind)}`);
|
|
131
|
+
}
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
reported(result, alwaysTrustSender);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
async function deleteMessage() {
|
|
138
|
+
await exclusive(async () => {
|
|
139
|
+
if (inDeletedItems) {
|
|
140
|
+
// Nowhere further to move it: asks first, deletes for good and tells the badges, the search index and the reader itself.
|
|
141
|
+
const outcome = await permanent.requestPermanentDelete([message]);
|
|
142
|
+
if (outcome && outcome.deleted.length > 0) {
|
|
143
|
+
onMoved?.(message);
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
// Awaited on its own line: an optional call with no callee never evaluates its arguments, so with no `onMoved` nothing would be moved.
|
|
149
|
+
const updated = await moveToType("deleted_items", "Deleted Items");
|
|
150
|
+
onMoved?.(updated);
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
notifyApiError(err, "Couldn't delete this message");
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
async function toggleRead() {
|
|
158
|
+
await exclusive(async () => {
|
|
159
|
+
const before = newest();
|
|
160
|
+
try {
|
|
161
|
+
await setReadStateMany([before], before.flags.read !== true, {
|
|
162
|
+
patch: (updated, previous) => {
|
|
163
|
+
remember(updated);
|
|
164
|
+
onChanged?.(updated, previous);
|
|
165
|
+
},
|
|
166
|
+
track: trackMessageChange,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
notifyApiError(err, "Couldn't update the message");
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async function toggleFlag() {
|
|
175
|
+
await exclusive(async () => {
|
|
176
|
+
const before = newest();
|
|
177
|
+
try {
|
|
178
|
+
const updated = await setMessageFlagged(before, before.flags.flagged !== true);
|
|
179
|
+
remember(updated);
|
|
180
|
+
onChanged?.(updated, before);
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
notifyApiError(err, "Couldn't update the message");
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/** The sender of this message as a list entry needs it: the address in its From header - what the reader sees, and what the mail server matches a list
|
|
188
|
+
* against (with the envelope sender) - or, without one, the address the message is filed under. `all` is both, for the filter rules of a server without lists. */
|
|
189
|
+
async function senders() {
|
|
190
|
+
const raw = await getMessageRawContent(message.uid).catch(() => undefined);
|
|
191
|
+
const header = raw === undefined ? undefined : headerFromAddress(raw);
|
|
192
|
+
return { listed: normalizeAddresses([header, message.from.address])[0], all: normalizeAddresses([message.from.address, header]) };
|
|
193
|
+
}
|
|
194
|
+
/** Whether `address` can go on a list (a plain address the mail server accepts); a pop-up says so when it cannot. */
|
|
195
|
+
function listable(address, title) {
|
|
196
|
+
const checked = address === undefined ? undefined : checkSenderEntry(address);
|
|
197
|
+
if (address !== undefined && checked?.ok && checked.kind === "address") {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
notify({ kind: "error", title, message: "This message has no sender address that can be put on a list." });
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
/** Files the message in its mailbox's Junk Email when it is not there yet, and says where it ended up. */
|
|
204
|
+
async function moveToJunkUnlessThere() {
|
|
205
|
+
if (inJunk) {
|
|
206
|
+
return "This message is already in Junk Email.";
|
|
207
|
+
}
|
|
208
|
+
try {
|
|
209
|
+
const moved = await moveToType("junk", "Junk Email");
|
|
210
|
+
onMoved?.(moved);
|
|
211
|
+
return "This message was moved there.";
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
notifyApiError(err, "Couldn't move this message to Junk Email");
|
|
215
|
+
return "This message is still where it was.";
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** Block, on a server without sender lists: the mailbox's mail filter rules. */
|
|
219
|
+
async function blockWithRules(addresses, address) {
|
|
220
|
+
let result;
|
|
221
|
+
try {
|
|
222
|
+
const [junkUid, inboxUid] = await Promise.all([folderOf("junk", "Junk Email"), folderOf("inbox", "Inbox")]);
|
|
223
|
+
result = await blockSender(message.mailboxUid, addresses, junkUid, inboxUid);
|
|
224
|
+
}
|
|
225
|
+
catch (err) {
|
|
226
|
+
notifyApiError(err, "Couldn't block this sender");
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const where = await moveToJunkUnlessThere();
|
|
230
|
+
notify({
|
|
231
|
+
kind: result.outcome === "existing" ? "info" : "success",
|
|
232
|
+
title: result.outcome === "existing" ? `${address} is already blocked` : `Blocked ${address}`,
|
|
233
|
+
message: `New mail from this address goes to Junk Email. ${where}`,
|
|
234
|
+
hint: "This server has no list of blocked senders, so the block is a filter rule that matches any sender address containing this one.",
|
|
235
|
+
actions: [
|
|
236
|
+
...(result.outcome === "created"
|
|
237
|
+
? [
|
|
238
|
+
{
|
|
239
|
+
label: "Undo",
|
|
240
|
+
onClick: () => {
|
|
241
|
+
removeSenderRule(result.rule).then(() => notify({ kind: "info", title: `Unblocked ${address}`, message: "The block was removed. This message stays where it is." }), (err) => notifyApiError(err, "Couldn't undo the block"));
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
]
|
|
245
|
+
: []),
|
|
246
|
+
{ label: "View rules", href: rulesHref(message.mailboxUid) },
|
|
247
|
+
],
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
async function block() {
|
|
251
|
+
await exclusive(async () => {
|
|
252
|
+
const { listed, all } = await senders();
|
|
253
|
+
if (!listable(listed, "Couldn't block this sender")) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (ownAddresses.includes(listed)) {
|
|
257
|
+
notify({ kind: "info", title: "That is your own address", message: `${listed} is one of your addresses, so it is not blocked.` });
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
let added;
|
|
261
|
+
try {
|
|
262
|
+
added = await addBlockedSender(message.mailboxUid, listed);
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
if (isNotFound(err)) {
|
|
266
|
+
await blockWithRules(all, message.from.address);
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
notifyApiError(err, "Couldn't block this sender");
|
|
270
|
+
}
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const where = await moveToJunkUnlessThere();
|
|
274
|
+
notify({
|
|
275
|
+
kind: added.changed ? "success" : "info",
|
|
276
|
+
title: added.changed ? `Blocked ${listed}` : `${listed} is already blocked`,
|
|
277
|
+
message: `New mail from this address goes to Junk Email. ${where}`,
|
|
278
|
+
actions: [
|
|
279
|
+
...(added.changed
|
|
280
|
+
? [
|
|
281
|
+
{
|
|
282
|
+
label: "Undo",
|
|
283
|
+
onClick: () => {
|
|
284
|
+
removeBlockedSender(message.mailboxUid, listed).then(() => notify({ kind: "info", title: `Unblocked ${listed}`, message: "The block was removed. This message stays where it is." }), (err) => notifyApiError(err, "Couldn't undo the block"));
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
]
|
|
288
|
+
: []),
|
|
289
|
+
{ label: "Manage blocked senders", href: senderListsHref(message.mailboxUid) },
|
|
290
|
+
],
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/** Never block, on a server without sender lists: the rule that keeps the sender's mail in the Inbox. */
|
|
295
|
+
async function neverBlockWithRules(addresses, address) {
|
|
296
|
+
let result;
|
|
297
|
+
try {
|
|
298
|
+
const [junkUid, inboxUid] = await Promise.all([folderOf("junk", "Junk Email"), folderOf("inbox", "Inbox")]);
|
|
299
|
+
result = await neverBlockSender(message.mailboxUid, addresses, junkUid, inboxUid);
|
|
300
|
+
}
|
|
301
|
+
catch (err) {
|
|
302
|
+
notifyApiError(err, "Couldn't stop blocking this sender");
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const unblocked = result.removed.length > 0 ? "The block on this sender was removed. " : "";
|
|
306
|
+
notify({
|
|
307
|
+
kind: result.outcome === "existing" && !unblocked ? "info" : "success",
|
|
308
|
+
title: result.outcome === "existing" && !unblocked ? `${address} is already never blocked` : `Never blocking ${address}`,
|
|
309
|
+
message: `${unblocked}New mail from this address stays in your Inbox, ahead of your other filters. Mail the spam filter judges to be junk still goes to Junk Email.`,
|
|
310
|
+
actions: [{ label: "View rules", href: rulesHref(message.mailboxUid) }],
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
async function neverBlock() {
|
|
314
|
+
await exclusive(async () => {
|
|
315
|
+
const { listed, all } = await senders();
|
|
316
|
+
if (!listable(listed, "Couldn't stop blocking this sender")) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
let added;
|
|
320
|
+
try {
|
|
321
|
+
added = await addSafeSender(message.mailboxUid, listed);
|
|
322
|
+
}
|
|
323
|
+
catch (err) {
|
|
324
|
+
if (isNotFound(err)) {
|
|
325
|
+
await neverBlockWithRules(all, message.from.address);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
notifyApiError(err, "Couldn't stop blocking this sender");
|
|
329
|
+
}
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
notify({
|
|
333
|
+
kind: added.changed ? "success" : "info",
|
|
334
|
+
title: added.changed ? `Never blocking ${listed}` : `${listed} is already a safe sender`,
|
|
335
|
+
message: "Any block on this address is removed. Mail from it that passes authentication is delivered to your Inbox instead of Junk Email; " +
|
|
336
|
+
"mail that fails authentication, carries a virus or is quarantined by policy is still kept out.",
|
|
337
|
+
actions: [
|
|
338
|
+
...(added.changed
|
|
339
|
+
? [
|
|
340
|
+
{
|
|
341
|
+
label: "Undo",
|
|
342
|
+
onClick: () => {
|
|
343
|
+
removeSafeSender(message.mailboxUid, listed).then(() => notify({ kind: "info", title: `${listed} is no longer a safe sender`, message: "Its mail is filtered as usual again." }), (err) => notifyApiError(err, "Couldn't undo the change"));
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
]
|
|
347
|
+
: []),
|
|
348
|
+
{ label: "Manage safe senders", href: senderListsHref(message.mailboxUid) },
|
|
349
|
+
],
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return {
|
|
354
|
+
busy: busy || permanent.busy,
|
|
355
|
+
dialog: permanent.dialog,
|
|
356
|
+
reportJunk: () => report("junk"),
|
|
357
|
+
reportPhishing: () => report("phishing"),
|
|
358
|
+
notJunk: () => report("not_junk"),
|
|
359
|
+
notJunkAndTrust: () => report("not_junk", true),
|
|
360
|
+
deleteMessage,
|
|
361
|
+
toggleRead,
|
|
362
|
+
toggleFlag,
|
|
363
|
+
blockSender: block,
|
|
364
|
+
neverBlockSender: neverBlock,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
@@ -11,7 +11,8 @@ import { listMailboxes } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
|
11
11
|
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
12
12
|
import Skeleton, { SkeletonList } from "@rapidmx/react-shared/components/feedback/Skeleton.js";
|
|
13
13
|
import AppShell from "../../layout/AppShell.js";
|
|
14
|
-
import {
|
|
14
|
+
import { useLocation } from "@rapidrest/react/client";
|
|
15
|
+
import { useNavigate } from "../../../navigation/index.js";
|
|
15
16
|
import MailboxProvisioning from "../../layout/MailboxProvisioning.js";
|
|
16
17
|
import { orderMailboxes, primaryMailboxUid } from "../../../mail/primaryMailbox.js";
|
|
17
18
|
import { mergePluginNavItems } from "../../../plugins/pluginNav.js";
|
|
@@ -21,6 +22,7 @@ export const SETTINGS_SECTIONS = [
|
|
|
21
22
|
{ id: "appearance", href: "/settings/appearance", label: "Appearance" },
|
|
22
23
|
{ id: "auto-reply", href: "/settings/auto-reply", label: "Automatic Replies" },
|
|
23
24
|
{ id: "filters", href: "/settings/filters", label: "Mail Filters" },
|
|
25
|
+
{ id: "blocked-senders", href: "/settings/blocked-senders", label: "Blocked & Safe Senders" },
|
|
24
26
|
{ id: "signatures", href: "/settings/signatures", label: "Signatures" },
|
|
25
27
|
{ id: "labels", href: "/settings/labels", label: "Labels" },
|
|
26
28
|
{ id: "read-receipts", href: "/settings/read-receipts", label: "Read Receipts" },
|
|
@@ -58,7 +60,7 @@ export default function SettingsShell({ active, userUid, authServerUrl, imperson
|
|
|
58
60
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
59
61
|
// Read from the router's location, so a mailbox change (a link, or `navigate()`) takes effect without a page load - and in an
|
|
60
62
|
// effect, not during render, so the server render and the hydrating render agree.
|
|
61
|
-
const search =
|
|
63
|
+
const { search } = useLocation();
|
|
62
64
|
const navigate = useNavigate();
|
|
63
65
|
useEffect(() => {
|
|
64
66
|
setRequestedMailboxUid(new URLSearchParams(search).get("mailboxUid"));
|
|
@@ -11,7 +11,8 @@ import { listFolders, listMailboxes } from "@rapidmx/react-shared/mail/mailApi.j
|
|
|
11
11
|
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
12
12
|
import Skeleton, { SkeletonList } from "@rapidmx/react-shared/components/feedback/Skeleton.js";
|
|
13
13
|
import AppShell from "../../layout/AppShell.js";
|
|
14
|
-
import {
|
|
14
|
+
import { useLocation } from "@rapidrest/react/client";
|
|
15
|
+
import { useNavigate } from "../../../navigation/index.js";
|
|
15
16
|
import MailboxProvisioning from "../../layout/MailboxProvisioning.js";
|
|
16
17
|
import { orderMailboxes, primaryMailboxUid } from "../../../mail/primaryMailbox.js";
|
|
17
18
|
const TasksShellContext = createContext({ mailboxes: [] });
|
|
@@ -36,7 +37,7 @@ export default function TasksShell({ userUid, authServerUrl, impersonating, impe
|
|
|
36
37
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
37
38
|
// Read from the router's location, so a mailbox change (a link, or `navigate()`) takes effect without a page load - and in an
|
|
38
39
|
// effect, not during render, so the server render and the hydrating render agree.
|
|
39
|
-
const search =
|
|
40
|
+
const { search } = useLocation();
|
|
40
41
|
const navigate = useNavigate();
|
|
41
42
|
useEffect(() => {
|
|
42
43
|
setRequestedMailboxUid(new URLSearchParams(search).get("mailboxUid"));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
///////////////////////////////////////////////////////////////////////////////
|
|
5
5
|
import { accountUrlOf } from "../auth/accountUrl.js";
|
|
6
6
|
import { APP_HREFS, SETTINGS_HREF, isSettingsPath } from "../navigation/appHrefs.js";
|
|
7
|
-
import { useNavigate } from "../navigation/
|
|
7
|
+
import { useNavigate } from "../navigation/index.js";
|
|
8
8
|
import { SHORTCUTS } from "./keymap.js";
|
|
9
9
|
import { useShortcut } from "./useShortcut.js";
|
|
10
10
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Folder } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
2
|
+
/** Forgets every remembered folder - for the tests. */
|
|
3
|
+
export declare function clearResolvedFolders(): void;
|
|
4
|
+
/**
|
|
5
|
+
* A mailbox's own folder of `type` (Junk Email, Deleted Items, Inbox) - the reading pane's counterpart of the mail page's bulk
|
|
6
|
+
* `resolveFolderOfType()`, so Report junk and Delete on one message go where the selection bar's go.
|
|
7
|
+
*
|
|
8
|
+
* Folders belong to a mailbox: only those of `mailboxUid` in `known` count (a message opened from a shared mailbox, or from a search
|
|
9
|
+
* over several, is filed in ITS mailbox's Junk, never the open one's). The server makes every well-known folder itself, so one the tree
|
|
10
|
+
* lacks is asked for - the tree may only be out of date - and used, never created twice; only a server that really has none is asked to
|
|
11
|
+
* make it. `onFound` is told about a folder the tree did not have, so the sidebar picks it up.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveFolderOfType(mailboxUid: string, type: Folder["type"], name: string, known?: Folder[], onFound?: (folder: Folder) => void): Promise<string>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import { createFolder, listFolders } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
6
|
+
/** The folders this page load has had to look up or make for a mailbox, so a second Report junk does not ask again. */
|
|
7
|
+
const resolved = new Map();
|
|
8
|
+
/** Forgets every remembered folder - for the tests. */
|
|
9
|
+
export function clearResolvedFolders() {
|
|
10
|
+
resolved.clear();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A mailbox's own folder of `type` (Junk Email, Deleted Items, Inbox) - the reading pane's counterpart of the mail page's bulk
|
|
14
|
+
* `resolveFolderOfType()`, so Report junk and Delete on one message go where the selection bar's go.
|
|
15
|
+
*
|
|
16
|
+
* Folders belong to a mailbox: only those of `mailboxUid` in `known` count (a message opened from a shared mailbox, or from a search
|
|
17
|
+
* over several, is filed in ITS mailbox's Junk, never the open one's). The server makes every well-known folder itself, so one the tree
|
|
18
|
+
* lacks is asked for - the tree may only be out of date - and used, never created twice; only a server that really has none is asked to
|
|
19
|
+
* make it. `onFound` is told about a folder the tree did not have, so the sidebar picks it up.
|
|
20
|
+
*/
|
|
21
|
+
export async function resolveFolderOfType(mailboxUid, type, name, known = [], onFound) {
|
|
22
|
+
const inTree = known.find((folder) => folder.mailboxUid === mailboxUid && folder.type === type);
|
|
23
|
+
if (inTree) {
|
|
24
|
+
return inTree.uid;
|
|
25
|
+
}
|
|
26
|
+
const key = `${mailboxUid}:${type}`;
|
|
27
|
+
const remembered = resolved.get(key);
|
|
28
|
+
if (remembered) {
|
|
29
|
+
return remembered;
|
|
30
|
+
}
|
|
31
|
+
const listed = (await listFolders(mailboxUid)).find((folder) => folder.type === type);
|
|
32
|
+
if (listed) {
|
|
33
|
+
onFound?.(listed);
|
|
34
|
+
resolved.set(key, listed.uid);
|
|
35
|
+
return listed.uid;
|
|
36
|
+
}
|
|
37
|
+
const created = await createFolder({ mailboxUid, name, type });
|
|
38
|
+
resolved.set(key, created.uid);
|
|
39
|
+
return created.uid;
|
|
40
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Message } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
2
|
+
/**
|
|
3
|
+
* Permanent delete: what "Delete" does to a message that is already in Deleted Items (and what "Empty folder" does to Deleted Items and
|
|
4
|
+
* Junk Email). Unlike a move into Deleted Items it cannot be undone, so it is never reached without a confirmation (see
|
|
5
|
+
* `usePermanentDelete()`, which asks it, runs what is in here and tells the folder badges and the reader).
|
|
6
|
+
*
|
|
7
|
+
* Server side it is `DELETE /mail/messages/:uid?purge=true` (a hard delete - the row and its search document are gone, not a
|
|
8
|
+
* recoverable soft delete) per message, and `DELETE /mail/messages?folderUid=` (`truncate`) for a whole folder. Both refuse a message under
|
|
9
|
+
* an active legal hold with a `409`; the per-message form refuses one message at a time, so a selection is deleted as far as it can be and
|
|
10
|
+
* each refusal is reported (`PurgeFailure`), rather than the first stopping the rest.
|
|
11
|
+
*/
|
|
12
|
+
/** How many purge requests are on the wire at once: a few at a time is quick, and the server publishes each folder's counts as they land. */
|
|
13
|
+
export declare const PURGE_CONCURRENCY = 4;
|
|
14
|
+
/** The folder types "Empty folder" is offered for: Outlook's Deleted Items and Junk Email. */
|
|
15
|
+
export declare const EMPTIABLE_FOLDER_TYPES: readonly string[];
|
|
16
|
+
/** A message the server refused to delete, and what it said. */
|
|
17
|
+
export interface PurgeFailure {
|
|
18
|
+
message: Message;
|
|
19
|
+
/** The server's own words (a legal hold names itself), or a stand-in when it did not answer. */
|
|
20
|
+
reason: string;
|
|
21
|
+
/** The response's status - `undefined` when there was no response. */
|
|
22
|
+
status?: number;
|
|
23
|
+
}
|
|
24
|
+
/** What deleting several messages came to: those that are gone, and those that are not (with why). Together they are all that was asked for. */
|
|
25
|
+
export interface PurgeOutcome {
|
|
26
|
+
deleted: Message[];
|
|
27
|
+
failed: PurgeFailure[];
|
|
28
|
+
}
|
|
29
|
+
/** What emptying a folder came to. */
|
|
30
|
+
export interface EmptyFolderOutcome extends PurgeOutcome {
|
|
31
|
+
/** Nothing is left in the folder as far as this knows: the whole-folder request went through, or every message listed was deleted. */
|
|
32
|
+
emptied: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** `1 message`, `3 messages`. */
|
|
35
|
+
export declare function messageCount(count: number): string;
|
|
36
|
+
/**
|
|
37
|
+
* Permanently deletes `messages`, each in its own request, a few at a time. Never rejects: a refusal (a legal hold, a share without the right
|
|
38
|
+
* to delete, a message that is already gone) is recorded against its message and the rest carry on. `deleted` and `failed` keep the order of
|
|
39
|
+
* `messages`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function purgeMessages(messages: Message[]): Promise<PurgeOutcome>;
|
|
42
|
+
/**
|
|
43
|
+
* Permanently deletes everything in `folderUid`: one request for the whole folder, which is all or nothing. The server refuses it as a whole
|
|
44
|
+
* when a message in it is under a legal hold (`409`) or when the caller may delete messages but not empty a folder (`403`, a delegate) - and
|
|
45
|
+
* then this lists the folder and deletes message by message instead, so what may go does and each refusal is reported. Any other failure
|
|
46
|
+
* (the server is down) rejects, and the caller says so.
|
|
47
|
+
*/
|
|
48
|
+
export declare function purgeFolder(folderUid: string, paging?: {
|
|
49
|
+
pageSize: number;
|
|
50
|
+
maxPages: number;
|
|
51
|
+
}): Promise<EmptyFolderOutcome>;
|
|
52
|
+
/**
|
|
53
|
+
* Tells the reader what a delete of several messages came to: "3 messages permanently deleted" (no Undo - there is none), or "2 deleted, 1
|
|
54
|
+
* could not be deleted" with the server's reasons.
|
|
55
|
+
*/
|
|
56
|
+
export declare function notifyPurged(outcome: PurgeOutcome): void;
|
|
57
|
+
/**
|
|
58
|
+
* Tells the reader what emptying `folderName` came to. `count` is how many messages it held, when that was known: the whole-folder request
|
|
59
|
+
* does not say. A folder that had to be deleted message by message reports as `notifyPurged()` does, plus a word when it was too big to be
|
|
60
|
+
* done in one go.
|
|
61
|
+
*/
|
|
62
|
+
export declare function notifyFolderEmptied(folderName: string, outcome: EmptyFolderOutcome, count?: number): void;
|