fluxmail 0.28.0 → 0.29.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/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/cliCloudClient.d.ts +2 -0
- package/dist/cliCloudClient.d.ts.map +1 -1
- package/dist/cliCloudClient.js +18 -3
- package/dist/cliCloudClient.js.map +1 -1
- package/dist/cliMail.d.ts +3 -0
- package/dist/cliMail.d.ts.map +1 -1
- package/dist/cliMail.js +18 -1
- package/dist/cliMail.js.map +1 -1
- package/dist/cliMailBackend.d.ts +3 -0
- package/dist/cliMailBackend.d.ts.map +1 -1
- package/dist/cliMailBackend.js +6 -0
- package/dist/cliMailBackend.js.map +1 -1
- package/dist/http/rest.d.ts.map +1 -1
- package/dist/http/rest.js +50 -6
- package/dist/http/rest.js.map +1 -1
- package/dist/mcp/buildServer.d.ts.map +1 -1
- package/dist/mcp/buildServer.js +31 -6
- package/dist/mcp/buildServer.js.map +1 -1
- package/dist/mcp/missingTools.d.ts +10 -0
- package/dist/mcp/missingTools.d.ts.map +1 -0
- package/dist/mcp/missingTools.js +50 -0
- package/dist/mcp/missingTools.js.map +1 -0
- package/dist/mcp/outputSchemas.d.ts +6 -0
- package/dist/mcp/outputSchemas.d.ts.map +1 -1
- package/dist/mcp/outputSchemas.js +1 -0
- package/dist/mcp/outputSchemas.js.map +1 -1
- package/dist/permissions.js +1 -1
- package/dist/permissions.js.map +1 -1
- package/dist/service/deliveryCoordinator.d.ts +16 -0
- package/dist/service/deliveryCoordinator.d.ts.map +1 -1
- package/dist/service/deliveryCoordinator.js +30 -3
- package/dist/service/deliveryCoordinator.js.map +1 -1
- package/dist/service/emailService.d.ts +25 -2
- package/dist/service/emailService.d.ts.map +1 -1
- package/dist/service/emailService.js +137 -46
- package/dist/service/emailService.js.map +1 -1
- package/dist/service/publicErrors.d.ts +4 -3
- package/dist/service/publicErrors.d.ts.map +1 -1
- package/dist/service/publicErrors.js +3 -2
- package/dist/service/publicErrors.js.map +1 -1
- package/dist/telemetry.d.ts +15 -0
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +22 -0
- package/dist/telemetry.js.map +1 -1
- package/package.json +9 -8
|
@@ -190,6 +190,8 @@ export declare class EmailService {
|
|
|
190
190
|
enforceQuota(): string | undefined;
|
|
191
191
|
private scheduledStatus;
|
|
192
192
|
listFolders(accountId?: string): Promise<Folder[]>;
|
|
193
|
+
/** Creates a folder, or returns the existing one with that name. */
|
|
194
|
+
createFolder(accountId: string | undefined, name: string): Promise<Folder>;
|
|
193
195
|
listLabels(accountId?: string): Promise<Label[]>;
|
|
194
196
|
listSendAs(accountId?: string): Promise<SendAsIdentity[]>;
|
|
195
197
|
replaceSendAs(accountId: string, identities: ConfiguredSendAsInput[]): Promise<SendAsIdentity[]>;
|
|
@@ -221,6 +223,23 @@ export declare class EmailService {
|
|
|
221
223
|
checkConfirmedSend(accountId: string | undefined, input: SendInput | {
|
|
222
224
|
draftId: string;
|
|
223
225
|
}, key: string): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Refuses a send made without the card when a card just sent the same email, so a user who clicked Send on
|
|
228
|
+
* the card and then told the assistant to send doesn't send it twice. It runs once the send has claimed
|
|
229
|
+
* its key and resolved its message, just before the message goes out or is saved to send later, so it sees
|
|
230
|
+
* a card send that started in the meantime and reads nothing from the provider itself. A failure to read
|
|
231
|
+
* the ledger must not stop the send.
|
|
232
|
+
*/
|
|
233
|
+
private refuseCardRepeat;
|
|
234
|
+
/**
|
|
235
|
+
* Reports a delivery that `refuseCardRepeat` stopped. The delivery is recorded as failed, so a retry of its
|
|
236
|
+
* key returns that, and this call tells the caller why. The error is made here, outside the provider call,
|
|
237
|
+
* so it carries no provider.
|
|
238
|
+
*/
|
|
239
|
+
private throwIfCardRepeat;
|
|
240
|
+
/** The preview a card shows for a resolved message, the body it sends, and so the hash the card gives it. */
|
|
241
|
+
private shownMessage;
|
|
242
|
+
private contentHash;
|
|
224
243
|
/**
|
|
225
244
|
* Stores a delivery's match digest. A failure must not stop the send: a delivery without a digest counts
|
|
226
245
|
* as the same email for every card issued before it, and a schedule without one also once it fires.
|
|
@@ -250,10 +269,14 @@ export declare class EmailService {
|
|
|
250
269
|
getDelivery(accountId: string | undefined, operationId: string): DeliveryOperation;
|
|
251
270
|
deliver(accountId: string | undefined, input: SendInput | {
|
|
252
271
|
draftId: string;
|
|
253
|
-
}, key: string
|
|
272
|
+
}, key: string, options?: {
|
|
273
|
+
refuseCardRepeat?: boolean;
|
|
274
|
+
}): Promise<DeliveryOperation>;
|
|
254
275
|
deliverForward(accountId: string | undefined, input: ForwardInput, key: string): Promise<DeliveryOperation>;
|
|
255
276
|
deliverScheduled(accountId: string, draftId: string, scheduleId: string, ownsClaim?: () => boolean): Promise<DeliveryOperation>;
|
|
256
|
-
scheduleDelivery(accountId: string | undefined, input: ScheduleInput, sendAt: string, key: string
|
|
277
|
+
scheduleDelivery(accountId: string | undefined, input: ScheduleInput, sendAt: string, key: string, options?: {
|
|
278
|
+
refuseCardRepeat?: boolean;
|
|
279
|
+
}): Promise<DeliveryOperation>;
|
|
257
280
|
send(accountId: string | undefined, input: SendInput | {
|
|
258
281
|
draftId: string;
|
|
259
282
|
}): Promise<SendResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emailService.d.ts","sourceRoot":"","sources":["../../src/service/emailService.ts"],"names":[],"mappings":"AAAA,OAAO,EAeL,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,K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B,0GAA0G;YAC5F,WAAW;IA6CzB;;;OAGG;IACH,OAAO,CAAC,YAAY;YA6BN,gBAAgB;YAkChB,cAAc;IAwBtB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;YAMxE,cAAc;IAY5B,+GAA+G;YACjG,YAAY;IAgDpB,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAyEvG,aAAa,CACX,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAOxE,OAAO,CAAC,iBAAiB;CAqB1B"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { assertSearchCapabilities, buildForwardBody, buildReplyBody, isValidTimeZone, quotedImages, computeReplyRecipients, EmailError, formatAddressList, forwardSubject, isEmailError, normalizeEmailQuery, parseSingleAddress, replySubject, selectReplySender, } from '@fluxmail/core';
|
|
2
2
|
import { createHmac, randomBytes } from 'node:crypto';
|
|
3
|
-
import { issueSendConfirmationKey, readSendConfirmationKey, sendConfirmationContentHash, sendConfirmationMatchHash, } from '@fluxmail/core/mcp';
|
|
3
|
+
import { isSendConfirmationKey, issueSendConfirmationKey, readSendConfirmationKey, repeatsCardSend, SEND_CONFIRMATION_REPEAT_MESSAGE, SEND_CONFIRMATION_REPEAT_WINDOW_MS, sendConfirmationContentHash, sendConfirmationKeyContentHash, sendConfirmationMatchHash, } from '@fluxmail/core/mcp';
|
|
4
4
|
import { SearchCursorCodec } from '@fluxmail/core/search-cursor';
|
|
5
5
|
import { assertWithinQuota, checkLicenseState } from '../licensing/entitlements.js';
|
|
6
6
|
import { listMembers } from '../storage/members.js';
|
|
7
7
|
import { canAccessAccount, canAdminister, canSeeAccountMetadata } from '../authorization.js';
|
|
8
8
|
import { hasCapability } from '../permissions.js';
|
|
9
9
|
import { cancelScheduledSend, countPending, createScheduledSend, findActiveByDraft, findPendingByDraft, getScheduledSend, listScheduledSends, markSent, updateActiveSummary, } from '../storage/scheduledSends.js';
|
|
10
|
-
import { DeliveryCoordinator, isDefiniteDeliveryFailure } from './deliveryCoordinator.js';
|
|
10
|
+
import { DeliveryCoordinator, deliveryFailure, isDefiniteDeliveryFailure, refuseBeforeSend, wasRefusedBeforeSend, } from './deliveryCoordinator.js';
|
|
11
11
|
import { asCardRefusal, ClientInputError, MissingCapabilityError, SendConfirmationError } from './publicErrors.js';
|
|
12
12
|
import { logFailure } from '../logging.js';
|
|
13
13
|
import { DEFAULT_MAX_ATTACHMENT_BYTES } from '../config.js';
|
|
@@ -299,6 +299,15 @@ export class EmailService {
|
|
|
299
299
|
listFolders(accountId) {
|
|
300
300
|
return this.withProvider(accountId, (p) => p.listFolders());
|
|
301
301
|
}
|
|
302
|
+
/** Creates a folder, or returns the existing one with that name. */
|
|
303
|
+
createFolder(accountId, name) {
|
|
304
|
+
return this.withProvider(accountId, (p) => {
|
|
305
|
+
if (!p.createFolder) {
|
|
306
|
+
throw new EmailError('unsupported_capability', 'This mailbox does not support creating folders.');
|
|
307
|
+
}
|
|
308
|
+
return p.createFolder(name);
|
|
309
|
+
});
|
|
310
|
+
}
|
|
302
311
|
listLabels(accountId) {
|
|
303
312
|
return this.withProvider(accountId, (p) => p.listLabels());
|
|
304
313
|
}
|
|
@@ -604,6 +613,91 @@ export class EmailService {
|
|
|
604
613
|
if (overtaken)
|
|
605
614
|
throw sent();
|
|
606
615
|
}
|
|
616
|
+
/**
|
|
617
|
+
* Refuses a send made without the card when a card just sent the same email, so a user who clicked Send on
|
|
618
|
+
* the card and then told the assistant to send doesn't send it twice. It runs once the send has claimed
|
|
619
|
+
* its key and resolved its message, just before the message goes out or is saved to send later, so it sees
|
|
620
|
+
* a card send that started in the meantime and reads nothing from the provider itself. A failure to read
|
|
621
|
+
* the ledger must not stop the send.
|
|
622
|
+
*/
|
|
623
|
+
refuseCardRepeat(coordinator, accountId, key, contentHash, sendsAt = Date.now()) {
|
|
624
|
+
// A card's own send is checked by `checkConfirmedSend`, and a forward is never what a card sent.
|
|
625
|
+
if (!contentHash || isSendConfirmationKey(key))
|
|
626
|
+
return;
|
|
627
|
+
let repeated;
|
|
628
|
+
try {
|
|
629
|
+
const cardSends = coordinator
|
|
630
|
+
.sendsSince(this.principal.memberId, accountId, sendsAt - SEND_CONFIRMATION_REPEAT_WINDOW_MS)
|
|
631
|
+
.flatMap(({ key: sentKey, sentAt }) => {
|
|
632
|
+
const sentHash = sendConfirmationKeyContentHash(sentKey);
|
|
633
|
+
return sentHash ? [{ contentHash: sentHash, sentAt }] : [];
|
|
634
|
+
});
|
|
635
|
+
repeated = cardSends.length > 0 && repeatsCardSend(contentHash(), cardSends, sendsAt);
|
|
636
|
+
}
|
|
637
|
+
catch (error) {
|
|
638
|
+
logFailure(this.logger, 'mail.card_repeat_check_failed', error);
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
if (repeated)
|
|
642
|
+
throw refuseBeforeSend(new SendConfirmationError(SEND_CONFIRMATION_REPEAT_MESSAGE));
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Reports a delivery that `refuseCardRepeat` stopped. The delivery is recorded as failed, so a retry of its
|
|
646
|
+
* key returns that, and this call tells the caller why. The error is made here, outside the provider call,
|
|
647
|
+
* so it carries no provider.
|
|
648
|
+
*/
|
|
649
|
+
throwIfCardRepeat(operation) {
|
|
650
|
+
if (wasRefusedBeforeSend(deliveryFailure(operation)?.cause)) {
|
|
651
|
+
throw asCardRefusal(new SendConfirmationError(SEND_CONFIRMATION_REPEAT_MESSAGE), 'repeated');
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
/** The preview a card shows for a resolved message, the body it sends, and so the hash the card gives it. */
|
|
655
|
+
shownMessage(resolvedId, account, message) {
|
|
656
|
+
if ('saved' in message) {
|
|
657
|
+
const draft = message.saved;
|
|
658
|
+
return {
|
|
659
|
+
preview: {
|
|
660
|
+
accountId: resolvedId,
|
|
661
|
+
from: draft.from?.email ?? account.email,
|
|
662
|
+
to: draft.to,
|
|
663
|
+
cc: draft.cc ?? [],
|
|
664
|
+
bcc: draft.bcc ?? [],
|
|
665
|
+
subject: draft.subject,
|
|
666
|
+
attachments: (draft.attachments ?? []).map(({ filename, mimeType, sizeBytes }) => ({
|
|
667
|
+
filename,
|
|
668
|
+
mimeType,
|
|
669
|
+
sizeBytes,
|
|
670
|
+
})),
|
|
671
|
+
bodyTextChars: draft.body?.text?.length ?? 0,
|
|
672
|
+
bodyHtmlChars: draft.body?.html?.length ?? 0,
|
|
673
|
+
},
|
|
674
|
+
body: draft.body ?? {},
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
const { draft: resolved, subject } = message;
|
|
678
|
+
return {
|
|
679
|
+
preview: {
|
|
680
|
+
accountId: resolvedId,
|
|
681
|
+
from: resolved.from ?? account.email,
|
|
682
|
+
to: resolved.to ?? [],
|
|
683
|
+
cc: resolved.cc ?? [],
|
|
684
|
+
bcc: resolved.bcc ?? [],
|
|
685
|
+
subject,
|
|
686
|
+
attachments: (resolved.attachments ?? []).map(({ filename, mimeType, content }) => ({
|
|
687
|
+
filename,
|
|
688
|
+
mimeType,
|
|
689
|
+
sizeBytes: Buffer.byteLength(content, 'base64'),
|
|
690
|
+
})),
|
|
691
|
+
bodyTextChars: resolved.body.text?.length ?? 0,
|
|
692
|
+
bodyHtmlChars: resolved.body.html?.length ?? 0,
|
|
693
|
+
},
|
|
694
|
+
body: resolved.body,
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
contentHash(resolvedId, account, message) {
|
|
698
|
+
const shown = this.shownMessage(resolvedId, account, message);
|
|
699
|
+
return sendConfirmationContentHash({ ...shown.preview, body: shown.body });
|
|
700
|
+
}
|
|
607
701
|
/**
|
|
608
702
|
* Stores a delivery's match digest. A failure must not stop the send: a delivery without a digest counts
|
|
609
703
|
* as the same email for every card issued before it, and a schedule without one also once it fires.
|
|
@@ -636,46 +730,24 @@ export class EmailService {
|
|
|
636
730
|
if (draft.from?.email && draft.from.email.toLowerCase() !== account.email.toLowerCase()) {
|
|
637
731
|
await this.validateSender(provider, resolvedId, account, draft.from.email);
|
|
638
732
|
}
|
|
639
|
-
const preview = {
|
|
640
|
-
accountId: resolvedId,
|
|
641
|
-
from: draft.from?.email ?? account.email,
|
|
642
|
-
to: draft.to,
|
|
643
|
-
cc: draft.cc ?? [],
|
|
644
|
-
bcc: draft.bcc ?? [],
|
|
645
|
-
subject: draft.subject,
|
|
646
|
-
attachments: (draft.attachments ?? []).map(({ filename, mimeType, sizeBytes }) => ({
|
|
647
|
-
filename,
|
|
648
|
-
mimeType,
|
|
649
|
-
sizeBytes,
|
|
650
|
-
})),
|
|
651
|
-
bodyTextChars: draft.body?.text?.length ?? 0,
|
|
652
|
-
bodyHtmlChars: draft.body?.html?.length ?? 0,
|
|
653
|
-
};
|
|
654
733
|
// Draft attachments carry no content, so the card shows their inline images as placeholders.
|
|
655
734
|
// A saved draft is sent as stored, so it keeps the name it has.
|
|
656
735
|
const fromName = options.senderName ? draft.from?.name : undefined;
|
|
657
|
-
return {
|
|
736
|
+
return {
|
|
737
|
+
...this.shownMessage(resolvedId, account, { saved: draft }),
|
|
738
|
+
inlineImages: [],
|
|
739
|
+
...(fromName ? { fromName } : {}),
|
|
740
|
+
};
|
|
658
741
|
}
|
|
659
742
|
this.assertMailContent(input);
|
|
660
743
|
const { draft: resolved, subject } = await this.resolveSend(provider, account, input);
|
|
661
|
-
const preview = {
|
|
662
|
-
accountId: resolvedId,
|
|
663
|
-
from: resolved.from ?? account.email,
|
|
664
|
-
to: resolved.to ?? [],
|
|
665
|
-
cc: resolved.cc ?? [],
|
|
666
|
-
bcc: resolved.bcc ?? [],
|
|
667
|
-
subject,
|
|
668
|
-
attachments: (resolved.attachments ?? []).map(({ filename, mimeType, content }) => ({
|
|
669
|
-
filename,
|
|
670
|
-
mimeType,
|
|
671
|
-
sizeBytes: Buffer.byteLength(content, 'base64'),
|
|
672
|
-
})),
|
|
673
|
-
bodyTextChars: resolved.body.text?.length ?? 0,
|
|
674
|
-
bodyHtmlChars: resolved.body.html?.length ?? 0,
|
|
675
|
-
};
|
|
676
744
|
const inlineImages = (resolved.attachments ?? []).filter((attachment) => attachment.contentId);
|
|
677
745
|
const fromName = options.senderName ? await this.senderName(provider, resolved.from) : undefined;
|
|
678
|
-
return {
|
|
746
|
+
return {
|
|
747
|
+
...this.shownMessage(resolvedId, account, { draft: resolved, subject }),
|
|
748
|
+
inlineImages,
|
|
749
|
+
...(fromName ? { fromName } : {}),
|
|
750
|
+
};
|
|
679
751
|
});
|
|
680
752
|
}
|
|
681
753
|
/**
|
|
@@ -709,7 +781,9 @@ export class EmailService {
|
|
|
709
781
|
throw new EmailError('permission_denied', 'A member session is required.');
|
|
710
782
|
return new DeliveryCoordinator(this.db).get(this.principal.principalId, this.principal.memberId, resolvedId, operationId);
|
|
711
783
|
}
|
|
712
|
-
async deliver(accountId, input, key
|
|
784
|
+
async deliver(accountId, input, key,
|
|
785
|
+
// Set for a send an assistant makes over MCP, which may repeat one its user just made from the card.
|
|
786
|
+
options = {}) {
|
|
713
787
|
const resolvedId = this.resolveScopedAccountId(accountId);
|
|
714
788
|
if (!this.principal)
|
|
715
789
|
throw new EmailError('permission_denied', 'A member session is required.');
|
|
@@ -723,8 +797,12 @@ export class EmailService {
|
|
|
723
797
|
key,
|
|
724
798
|
kind: 'send',
|
|
725
799
|
request: input,
|
|
726
|
-
}, async () => (sent = await this.sendMessage(resolvedId, input, (message) =>
|
|
727
|
-
.
|
|
800
|
+
}, async () => (sent = await this.sendMessage(resolvedId, input, (message, contentHash) => {
|
|
801
|
+
if (options.refuseCardRepeat)
|
|
802
|
+
this.refuseCardRepeat(coordinator, resolvedId, key, contentHash);
|
|
803
|
+
this.recordMatch(coordinator, key, message);
|
|
804
|
+
})).result);
|
|
805
|
+
this.throwIfCardRepeat(operation);
|
|
728
806
|
await this.markOriginal(resolvedId, sent);
|
|
729
807
|
return operation;
|
|
730
808
|
}
|
|
@@ -765,22 +843,34 @@ export class EmailService {
|
|
|
765
843
|
return result;
|
|
766
844
|
}), ownsClaim);
|
|
767
845
|
}
|
|
768
|
-
scheduleDelivery(accountId, input, sendAt, key
|
|
846
|
+
scheduleDelivery(accountId, input, sendAt, key,
|
|
847
|
+
// Set for a schedule an assistant makes over MCP, which may repeat a send its user just made from the card.
|
|
848
|
+
options = {}) {
|
|
769
849
|
const resolvedId = this.resolveScopedAccountId(accountId);
|
|
770
850
|
if (!this.principal)
|
|
771
851
|
throw new EmailError('permission_denied', 'A member session is required.');
|
|
772
852
|
let createdSchedule = false;
|
|
773
853
|
const coordinator = new DeliveryCoordinator(this.db);
|
|
774
|
-
const scheduled = coordinator
|
|
854
|
+
const scheduled = coordinator
|
|
855
|
+
.schedule({
|
|
775
856
|
principalId: this.principal.principalId,
|
|
776
857
|
memberId: this.principal.memberId,
|
|
777
858
|
accountId: resolvedId,
|
|
778
859
|
key,
|
|
779
860
|
request: { input, sendAt },
|
|
780
861
|
}, async () => {
|
|
781
|
-
const result = await this.createSchedule(resolvedId, input, sendAt, (message
|
|
862
|
+
const result = await this.createSchedule(resolvedId, input, sendAt, (message, contentHash, sendTime) => {
|
|
863
|
+
if (options.refuseCardRepeat) {
|
|
864
|
+
this.refuseCardRepeat(coordinator, resolvedId, key, contentHash, sendTime);
|
|
865
|
+
}
|
|
866
|
+
this.recordMatch(coordinator, key, message);
|
|
867
|
+
});
|
|
782
868
|
createdSchedule = true;
|
|
783
869
|
return result;
|
|
870
|
+
})
|
|
871
|
+
.then((operation) => {
|
|
872
|
+
this.throwIfCardRepeat(operation);
|
|
873
|
+
return operation;
|
|
784
874
|
});
|
|
785
875
|
return scheduled.finally(() => {
|
|
786
876
|
if (createdSchedule)
|
|
@@ -803,7 +893,7 @@ export class EmailService {
|
|
|
803
893
|
}
|
|
804
894
|
// Sending removes the draft, so find the message it replies to first.
|
|
805
895
|
const repliedTo = await this.findRepliedMessage(p, input.draftId);
|
|
806
|
-
onResolved?.(draft);
|
|
896
|
+
onResolved?.(draft, () => this.contentHash(resolvedId, account, { saved: draft }));
|
|
807
897
|
const result = await p.send({ draftId: input.draftId });
|
|
808
898
|
// Sending a scheduled draft now supersedes its schedule.
|
|
809
899
|
const pending = findPendingByDraft(this.db, resolvedId, input.draftId);
|
|
@@ -814,7 +904,7 @@ export class EmailService {
|
|
|
814
904
|
return { result, ...(repliedTo ? { original: { id: repliedTo, action: 'reply' } } : {}) };
|
|
815
905
|
}
|
|
816
906
|
const { draft, subject } = await this.resolveSend(p, account, input);
|
|
817
|
-
onResolved?.({ ...draft, subject });
|
|
907
|
+
onResolved?.({ ...draft, subject }, () => this.contentHash(resolvedId, account, { draft, subject }));
|
|
818
908
|
const result = await p.send(draft);
|
|
819
909
|
return {
|
|
820
910
|
result,
|
|
@@ -866,13 +956,14 @@ export class EmailService {
|
|
|
866
956
|
// provider saves the draft, which may not return every field.
|
|
867
957
|
let message;
|
|
868
958
|
if ('draftId' in input) {
|
|
869
|
-
|
|
870
|
-
|
|
959
|
+
const saved = await p.getDraft(input.draftId);
|
|
960
|
+
message = saved;
|
|
961
|
+
onResolved?.(saved, () => this.contentHash(id, account, { saved }), sendAt);
|
|
871
962
|
}
|
|
872
963
|
else if ('forward' in input) {
|
|
873
964
|
// A scheduled forward is saved as a draft now, with the original's attachments, and sent later.
|
|
874
965
|
const { draft: forward } = await this.forwardDraft(p, id, account, input.forward);
|
|
875
|
-
onResolved?.(forward);
|
|
966
|
+
onResolved?.(forward, undefined, sendAt);
|
|
876
967
|
message = await p.createDraft(forward);
|
|
877
968
|
}
|
|
878
969
|
else {
|
|
@@ -880,7 +971,7 @@ export class EmailService {
|
|
|
880
971
|
if (!resolved.to?.length && !resolved.cc?.length && !resolved.bcc?.length) {
|
|
881
972
|
throw new ClientInputError('invalid_request', 'Cannot schedule a message with no recipients');
|
|
882
973
|
}
|
|
883
|
-
onResolved?.({ ...resolved, subject });
|
|
974
|
+
onResolved?.({ ...resolved, subject }, () => this.contentHash(id, account, { draft: resolved, subject }), sendAt);
|
|
884
975
|
message = await p.createDraft(resolved);
|
|
885
976
|
}
|
|
886
977
|
return { draft: message, resolvedId: id };
|