@social-mail/social-mail-web-server 1.7.412 → 1.7.415
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/server/seed/ui/seed-ui.js +2 -2
- package/dist/server/smtp/services/EmailPostReceiveService.d.ts.map +1 -1
- package/dist/server/smtp/services/EmailPostReceiveService.js +9 -0
- package/dist/server/smtp/services/EmailPostReceiveService.js.map +1 -1
- package/dist/server/smtp/services/EmailSerializerService.d.ts.map +1 -1
- package/dist/server/smtp/services/EmailSerializerService.js +5 -0
- package/dist/server/smtp/services/EmailSerializerService.js.map +1 -1
- package/dist/server/smtp/services/MailReceiverService.d.ts +0 -1
- package/dist/server/smtp/services/MailReceiverService.d.ts.map +1 -1
- package/dist/server/smtp/services/MailReceiverService.js +0 -5
- package/dist/server/smtp/services/MailReceiverService.js.map +1 -1
- package/dist/server/workflows/SocialWorkflowContext.d.ts.map +1 -1
- package/dist/server/workflows/SocialWorkflowContext.js +2 -0
- package/dist/server/workflows/SocialWorkflowContext.js.map +1 -1
- package/dist/server/workflows/channel/BroadcastEmail.d.ts.map +1 -1
- package/dist/server/workflows/channel/BroadcastEmail.js +1 -0
- package/dist/server/workflows/channel/BroadcastEmail.js.map +1 -1
- package/dist/server/workflows/channel/library/SendLibraryContentWorkflow.d.ts +15 -0
- package/dist/server/workflows/channel/library/SendLibraryContentWorkflow.d.ts.map +1 -0
- package/dist/server/workflows/channel/library/SendLibraryContentWorkflow.js +153 -0
- package/dist/server/workflows/channel/library/SendLibraryContentWorkflow.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/server/seed/ui/seed-ui.ts +2 -2
- package/src/server/smtp/services/EmailPostReceiveService.ts +11 -0
- package/src/server/smtp/services/EmailSerializerService.ts +6 -0
- package/src/server/smtp/services/MailReceiverService.ts +0 -7
- package/src/server/workflows/SocialWorkflowContext.ts +2 -0
- package/src/server/workflows/channel/BroadcastEmail.ts +1 -0
- package/src/server/workflows/channel/library/SendLibraryContentWorkflow.ts +105 -0
package/package.json
CHANGED
|
@@ -5,13 +5,13 @@ export default async function seedUI(config: DBConfig) {
|
|
|
5
5
|
await config.saveVersion(UIPackageConfig, {
|
|
6
6
|
package: "@social-mail/social-mail-client",
|
|
7
7
|
view: "dist/web/AppIndex",
|
|
8
|
-
version: "1.5.
|
|
8
|
+
version: "1.5.33"
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
await config.saveVersion(WebComponentsPackageConfig, {
|
|
12
12
|
package: "@social-mail/web-components",
|
|
13
13
|
view: "dist/index.js",
|
|
14
|
-
version: "1.0.
|
|
14
|
+
version: "1.0.201"
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
await config.saveVersion(FAFreePackageConfig, {
|
|
@@ -17,6 +17,7 @@ import EmailThreadService from "../../services/threads/EmailThreadService.js";
|
|
|
17
17
|
import ChannelModerationService from "../../services/channels/ChannelModerationService.js";
|
|
18
18
|
import Mailbox from "../../model/entities/Mailbox.js";
|
|
19
19
|
import UpdatePendingModerationCountWorkflow from "../../workflows/channel/moderation/UpdatePendingModerationCountWorkflow.js";
|
|
20
|
+
import SendLibraryContentWorkflow from "../../workflows/channel/library/SendLibraryContentWorkflow.js";
|
|
20
21
|
|
|
21
22
|
@RegisterScoped
|
|
22
23
|
export default class EmailPostReceiveService {
|
|
@@ -146,6 +147,16 @@ export default class EmailPostReceiveService {
|
|
|
146
147
|
await this.ets.unsubscribe(senderID, emailID);
|
|
147
148
|
return;
|
|
148
149
|
case "➕":
|
|
150
|
+
|
|
151
|
+
if(channel.isLibrary) {
|
|
152
|
+
// send all...
|
|
153
|
+
await SendLibraryContentWorkflow.broadcast(this.context, {
|
|
154
|
+
channelID: channel.mailboxID,
|
|
155
|
+
from: channel.emailAddress.emailAddress,
|
|
156
|
+
recipientID: senderID
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
149
160
|
await BroadcastEmail.broadcast(this.context, {
|
|
150
161
|
mailboxID: recipientID,
|
|
151
162
|
emailID,
|
|
@@ -426,6 +426,12 @@ export default class EmailSerializerService {
|
|
|
426
426
|
|
|
427
427
|
if (mailbox.isChannel) {
|
|
428
428
|
|
|
429
|
+
if (!engagement) {
|
|
430
|
+
if(subject.startsWith("subscribe")) {
|
|
431
|
+
engagement = "➕";
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
429
435
|
// if it is engagement...
|
|
430
436
|
if (!/^(➕-)?subscribe/ui.test(subject)) {
|
|
431
437
|
|
|
@@ -10,7 +10,6 @@ import TempFileService from "../../storage/TempFileService.js";
|
|
|
10
10
|
import { AddressObject, ParsedMail, simpleParser } from "mailparser";
|
|
11
11
|
import { authenticate } from "mailauth";
|
|
12
12
|
import EmailAddressService from "../../services/EmailAddressService.js";
|
|
13
|
-
import WorkflowContext from "../../workflows/SocialWorkflowContext.js";
|
|
14
13
|
import { SmtpStatusCodes } from "../client/SmtpStatusCodes.js";
|
|
15
14
|
import { isTestMode } from "../../../globalServices.js";
|
|
16
15
|
import EmailSerializerService from "./EmailSerializerService.js";
|
|
@@ -18,11 +17,8 @@ import ChannelService from "./ChannelService.js";
|
|
|
18
17
|
import { globalEnv } from "../../../common/globalEnv.js";
|
|
19
18
|
import { LocalFile } from "@entity-access/server-pages/dist/core/LocalFile.js";
|
|
20
19
|
import sleep from "../../../common/sleep.js";
|
|
21
|
-
import EmailAddress from "../../model/entities/EmailAddress.js";
|
|
22
|
-
import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
|
|
23
20
|
import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
|
|
24
21
|
import { serverActivities } from "../../model/entities/ServerActivity.js";
|
|
25
|
-
import AccessTokenService from "./AccessTokenService.js";
|
|
26
22
|
import EntityAccessError from "@entity-access/entity-access/dist/common/EntityAccessError.js";
|
|
27
23
|
import TagService from "../../services/tags/TagService.js";
|
|
28
24
|
import DomainReputationService from "./DomainReputationService.js";
|
|
@@ -84,9 +80,6 @@ export default class MailReceiverService {
|
|
|
84
80
|
@Inject
|
|
85
81
|
private db: SocialMailContext;
|
|
86
82
|
|
|
87
|
-
@Inject
|
|
88
|
-
private storage: BaseStorage;
|
|
89
|
-
|
|
90
83
|
@Inject
|
|
91
84
|
private tempFileService: TempFileService;
|
|
92
85
|
|
|
@@ -51,6 +51,7 @@ import DeleteMailboxContactWorkflow from "./mailbox/DeleteMailboxContactWorkflow
|
|
|
51
51
|
import DownloadExternalAttachmentWorkflow from "./external-body/DownloadExternalAttachmentWorkflow.js";
|
|
52
52
|
import FetchCheckoutResultWorkflow from "./store/FetchCheckoutResultWorkflow.js";
|
|
53
53
|
import DeleteWebSiteVersionWorkflow from "./web-site/DeleteWebSiteVersionWorkflow.js";
|
|
54
|
+
import SendLibraryContentWorkflow from "./channel/library/SendLibraryContentWorkflow.js";
|
|
54
55
|
|
|
55
56
|
@RegisterSingleton
|
|
56
57
|
export default class SocialWorkflowContext extends WorkflowContext {
|
|
@@ -113,6 +114,7 @@ export default class SocialWorkflowContext extends WorkflowContext {
|
|
|
113
114
|
this.register(DownloadExternalAttachmentWorkflow);
|
|
114
115
|
|
|
115
116
|
this.register(FetchCheckoutResultWorkflow);
|
|
117
|
+
this.register(SendLibraryContentWorkflow);
|
|
116
118
|
|
|
117
119
|
// start processing...
|
|
118
120
|
// this.start().catch((error) => console.error(error));
|
|
@@ -211,6 +211,7 @@ export default class BroadcastEmail extends Workflow<IBroadcastEmail> {
|
|
|
211
211
|
|
|
212
212
|
return db.mailboxContacts.where(input, (p) => (x) => x.mailboxID === p.mailboxID
|
|
213
213
|
&& x.emailAddressID !== p.mailboxID
|
|
214
|
+
&& x.emailAddressID !== p.senderID
|
|
214
215
|
&& !x.emailAddress.subscriberActivities.some((sa) => sa.emailID === p.emailID)
|
|
215
216
|
&& x.status === "active"
|
|
216
217
|
&& (x.subscriptionType === null
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import Workflow, { UniqueActivity } from "@entity-access/entity-access/dist/workflows/Workflow.js";
|
|
2
|
+
import SocialMailContext from "../../../model/SocialMailContext.js";
|
|
3
|
+
import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import DispatchEmailToMX from "../../smtp/DispatchEmailToMX.js";
|
|
6
|
+
import BroadcastEmail from "../BroadcastEmail.js";
|
|
7
|
+
import WorkflowContext from "@entity-access/entity-access/dist/workflows/WorkflowContext.js";
|
|
8
|
+
|
|
9
|
+
export interface ISendLibraryContentWorkflowParams {
|
|
10
|
+
channelID, recipientID, from: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default class SendLibraryContentWorkflow extends Workflow<ISendLibraryContentWorkflowParams> {
|
|
14
|
+
|
|
15
|
+
static taskGroup = "batch";
|
|
16
|
+
|
|
17
|
+
static broadcast(context: WorkflowContext, input: ISendLibraryContentWorkflowParams ) {
|
|
18
|
+
return context.queue(SendLibraryContentWorkflow, input, {
|
|
19
|
+
id: `library-broadcast-${input.channelID}-${input.recipientID}`,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async run() {
|
|
24
|
+
let start = BigInt(0);
|
|
25
|
+
for(;;) {
|
|
26
|
+
start = await this.send(start);
|
|
27
|
+
if (!BigInt(start)) {
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@UniqueActivity
|
|
34
|
+
async send(
|
|
35
|
+
start,
|
|
36
|
+
db?: SocialMailContext
|
|
37
|
+
) {
|
|
38
|
+
|
|
39
|
+
const { channelID, recipientID } = this.input;
|
|
40
|
+
|
|
41
|
+
const list = await db.channelEmails.where({ channelID, start, recipientID }, (p) => (x) => x.mailboxID === p.channelID
|
|
42
|
+
&& x.emailID > p.start
|
|
43
|
+
&& x.datePublished !== null
|
|
44
|
+
&& x.email.status === "published"
|
|
45
|
+
&& !x.email.subscriberActivities.some((e) => e.emailAddressID === p.recipientID)
|
|
46
|
+
)
|
|
47
|
+
.orderBy(void 0, (p) => (x) => x.emailID)
|
|
48
|
+
.limit(100)
|
|
49
|
+
.include((x) => x.email.senderEmail)
|
|
50
|
+
.toArray();
|
|
51
|
+
|
|
52
|
+
if(!list.length) {
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let eta = this.currentTime;
|
|
57
|
+
|
|
58
|
+
const emailAddressID = recipientID;
|
|
59
|
+
const { from } = this.input;
|
|
60
|
+
|
|
61
|
+
for (const { email: { emailID, dateCreated, senderID, senderEmail: { emailAddress: to } } } of list) {
|
|
62
|
+
const accessCode = randomUUID().replaceAll("-", "");
|
|
63
|
+
|
|
64
|
+
await using tx = await db.connection.createTransaction();
|
|
65
|
+
const activity = await db.subscriberActivities.statements.insert({
|
|
66
|
+
activity: "scheduled",
|
|
67
|
+
emailID,
|
|
68
|
+
emailAddressID,
|
|
69
|
+
mailboxID: channelID,
|
|
70
|
+
accessCode,
|
|
71
|
+
dateCreated
|
|
72
|
+
});
|
|
73
|
+
const host = to.split("@").pop();
|
|
74
|
+
|
|
75
|
+
const { activityID } = activity;
|
|
76
|
+
|
|
77
|
+
await this.context.queue(DispatchEmailToMX, {
|
|
78
|
+
recipientAddressID: emailAddressID,
|
|
79
|
+
emailID,
|
|
80
|
+
senderID,
|
|
81
|
+
external: false,
|
|
82
|
+
doNotSendDR: true,
|
|
83
|
+
saveHeadersOnly: true,
|
|
84
|
+
activityID,
|
|
85
|
+
accessCode,
|
|
86
|
+
from,
|
|
87
|
+
to: [to],
|
|
88
|
+
modifyTo: true,
|
|
89
|
+
listID: senderID,
|
|
90
|
+
host,
|
|
91
|
+
}, {
|
|
92
|
+
id: `bulk-dispatch-to-mx-${activityID}`,
|
|
93
|
+
eta,
|
|
94
|
+
taskGroup: BroadcastEmail.taskGroup
|
|
95
|
+
});
|
|
96
|
+
await tx.commit();
|
|
97
|
+
eta = eta.addSeconds(15);
|
|
98
|
+
|
|
99
|
+
db.changeSet.clear();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return start;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|