@social-mail/social-mail-web-server 1.7.78 → 1.7.80

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.
Files changed (35) hide show
  1. package/dist/server/model/events/EmailEvents.d.ts.map +1 -1
  2. package/dist/server/model/events/EmailEvents.js +7 -5
  3. package/dist/server/model/events/EmailEvents.js.map +1 -1
  4. package/dist/server/services/email-logs/EmailLogService.d.ts +1 -0
  5. package/dist/server/services/email-logs/EmailLogService.d.ts.map +1 -1
  6. package/dist/server/services/email-logs/EmailLogService.js +66 -0
  7. package/dist/server/services/email-logs/EmailLogService.js.map +1 -1
  8. package/dist/server/workflows/channel/BroadcastEmail.d.ts.map +1 -1
  9. package/dist/server/workflows/channel/BroadcastEmail.js +1 -0
  10. package/dist/server/workflows/channel/BroadcastEmail.js.map +1 -1
  11. package/dist/server/workflows/smtp/DispatchEmailToMX.d.ts +1 -15
  12. package/dist/server/workflows/smtp/DispatchEmailToMX.d.ts.map +1 -1
  13. package/dist/server/workflows/smtp/DispatchEmailToMX.js +11 -2
  14. package/dist/server/workflows/smtp/DispatchEmailToMX.js.map +1 -1
  15. package/dist/server/workflows/smtp/IMessageEnvelope.d.ts +16 -0
  16. package/dist/server/workflows/smtp/IMessageEnvelope.d.ts.map +1 -0
  17. package/dist/server/workflows/smtp/IMessageEnvelope.js +2 -0
  18. package/dist/server/workflows/smtp/IMessageEnvelope.js.map +1 -0
  19. package/dist/server/workflows/smtp/MailDispatcherService.d.ts +5 -12
  20. package/dist/server/workflows/smtp/MailDispatcherService.d.ts.map +1 -1
  21. package/dist/server/workflows/smtp/MailDispatcherService.js +15 -4
  22. package/dist/server/workflows/smtp/MailDispatcherService.js.map +1 -1
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +1 -1
  25. package/src/server/model/events/EmailEvents.ts +7 -4
  26. package/src/server/services/email-logs/EmailLogService.ts +8 -0
  27. package/src/server/workflows/channel/BroadcastEmail.ts +1 -0
  28. package/src/server/workflows/smtp/DispatchEmailToMX.ts +15 -20
  29. package/src/server/workflows/smtp/IMessageEnvelope.ts +15 -0
  30. package/src/server/workflows/smtp/MailDispatcherService.ts +22 -6
  31. package/dist/server/workflows/channel/BroadcastEmailToMX.d.ts +0 -2
  32. package/dist/server/workflows/channel/BroadcastEmailToMX.d.ts.map +0 -1
  33. package/dist/server/workflows/channel/BroadcastEmailToMX.js +0 -219
  34. package/dist/server/workflows/channel/BroadcastEmailToMX.js.map +0 -1
  35. package/src/server/workflows/channel/BroadcastEmailToMX.ts +0 -257
@@ -1,257 +0,0 @@
1
- // import Inject from "@entity-access/entity-access/dist/di/di.js";
2
- // import Workflow, { UniqueActivity } from "@entity-access/entity-access/dist/workflows/Workflow.js";
3
- // import TempFileService from "../../storage/TempFileService.js";
4
- // import TimeSpan from "@entity-access/entity-access/dist/types/TimeSpan.js";
5
- // import { SmtpStatusCodes } from "../../smtp/client/SmtpStatusCodes.js";
6
- // import { ISmtpResponse } from "../../smtp/client/SMTPClient.js";
7
- // import SocialMailContext from "../../model/SocialMailContext.js";
8
- // import SubscriberActivity from "../../model/entities/SubscriberActivity.js";
9
- // import AppFile from "../../model/entities/AppFile.js";
10
- // import { Attachment } from "nodemailer/lib/mailer/index.js";
11
- // import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
12
- // import DKIM from "nodemailer/lib/dkim/index.js";
13
- // import MailComposer from "nodemailer/lib/mail-composer/index.js";
14
- // import { expandPlaceholders } from "../../services/TemplateExpander.js";
15
- // import HtmlSanitizer from "../../services/dom/HtmlSanitizer.js";
16
- // import sleep from "../../../common/sleep.js";
17
- // import { Base36 } from "../../../common/Base36.js";
18
- // import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
19
- // import Tracer from "../../../Tracer.js";
20
- // import EngagementService from "../../smtp/services/EngagementService.js";
21
- // import { smtpPool } from "../smtp/DispatchEmailToMX.js";
22
- // import EmailLogService from "../../services/email-logs/EmailLogService.js";
23
-
24
- // export default class BroadcastEmailToMX extends Workflow<SubscriberActivity> {
25
-
26
- // private response: ISmtpResponse;
27
-
28
- // async run() {
29
- // let ts = TimeSpan.fromSeconds(60);
30
-
31
- // for (let index = 0; index < 5; index++) {
32
-
33
- // const status = this.response = await this.sendMail(index);
34
-
35
- // switch(status.statusCode) {
36
- // case SmtpStatusCodes.Ok:
37
- // await this.saveStatus();
38
- // return null;
39
- // case SmtpStatusCodes.ExceededStorageAllocation:
40
- // case SmtpStatusCodes.MailboxBusy:
41
- // case SmtpStatusCodes.TransactionFailed:
42
- // case SmtpStatusCodes.ServiceNotAvailable:
43
- // break;
44
- // default:
45
- // await this.saveStatus();
46
- // return status.status;
47
- // }
48
-
49
- // await this.delay(ts);
50
- // ts = ts.add(ts);
51
- // }
52
-
53
- // await this.saveStatus();
54
- // return "Failed after multiple attempts";
55
- // }
56
-
57
- // @UniqueActivity
58
- // async sendMail(
59
- // attempt: number,
60
- // @Inject db?: SocialMailContext,
61
- // @Inject tfs?: TempFileService,
62
- // @Inject es?: EngagementService,
63
- // @Inject htmlSanitizer?: HtmlSanitizer
64
- // ) {
65
- // const { activityID, emailID } = this.input;
66
-
67
- // db.verifyFilters = false;
68
- // db.raiseEvents = false;
69
-
70
- // const activity = await db.subscriberActivities
71
- // .where(this.input, (p) => (x) => x.activityID === p.activityID)
72
- // .include((x) => [
73
- // x.email.attachments,
74
- // x.email.senderEmail,
75
- // x.subscriber.mailbox,
76
- // x.subscriber.domain,
77
- // x.mailbox.emailAddress,
78
- // x.mailbox.domain.domainKeys
79
- // ])
80
- // .first();
81
-
82
- // const uid = activity.activityID;
83
-
84
- // const email = activity.email;
85
-
86
- // const to = activity.subscriber.emailAddress;
87
- // const headers = JSON.parse(email.headers ?? "{}");
88
-
89
- // let { inReplyTo } = headers;
90
-
91
- // if (email.parent) {
92
- // inReplyTo = `<${email.parent.headerMessageID}>`;
93
- // }
94
-
95
- // if (inReplyTo) {
96
- // if (!inReplyTo.startsWith("<")) {
97
- // inReplyTo = `<${inReplyTo}>`;
98
- // }
99
- // }
100
-
101
- // const senderEmail = activity.mailbox.emailAddress.emailAddress;
102
-
103
- // let html = email.htmlBody;
104
- // const s = htmlSanitizer.sanitize(html, email.textBody, {
105
- // senderEmail,
106
- // uid: Base36.encode(uid),
107
- // emailID: Base36.encode(emailID),
108
- // messageID: email.headerMessageID,
109
- // activityID: Base36.encode(activityID) as any,
110
- // });
111
-
112
- // html = s.html;
113
-
114
- // const senderName = activity.mailbox.emailAddress.name || activity.mailbox.name;
115
-
116
- // const now = DateTime.now;
117
-
118
- // if (!email.senderName) {
119
- // email.senderName = senderName;
120
- // }
121
-
122
- // const toAttachment = async (ea: AppFile): Promise<Attachment> => {
123
- // const tf = await tfs.downloadAppFile(ea);
124
- // return {
125
- // content: tf.openReadStream(),
126
- // filename: ea.name,
127
- // contentType: ea.contentType,
128
- // contentDisposition: ea.contentDisposition as any,
129
- // cid: ea.appFileID.toString()
130
- // };
131
- // };
132
-
133
- // const attachments = await Promise.all((email.attachments ?? []).map(toAttachment));
134
-
135
- // // prepare transport...
136
- // const mail = new MailComposer({
137
- // from: {
138
- // name: senderName,
139
- // address: senderEmail
140
- // },
141
- // to,
142
- // html,
143
- // text: email.textBody,
144
- // subject: email.subject,
145
- // messageId: email.headerMessageID,
146
- // inReplyTo,
147
- // attachments,
148
- // date: now.asJSDate,
149
- // headers: {
150
- // "Original-From": `"${senderName}" <${senderEmail}>`,
151
- // "List-Unsubscribe": `<mailto:unsubscribe-${senderEmail}>`
152
- // }
153
- // });
154
-
155
- // const mime = mail.compile();
156
-
157
- // const dk = activity.mailbox.domain.domainKeys[0];
158
-
159
- // const signer = new DKIM({
160
- // domainName: activity.mailbox.emailAddress.emailAddress.split("@").pop() ,
161
- // keySelector: dk.name,
162
- // privateKey: dk.privateKey
163
- // });
164
-
165
- // const mailFile = await tfs.createFrom(`${email.emailID}.eml`, signer.sign( mime.createReadStream()), "message/rfc822");
166
-
167
- // if (activity.subscriber.mailbox) {
168
-
169
- // const originalFile = db.appFiles.add({
170
- // name: "mail.eml",
171
- // contentType: mailFile.contentType,
172
- // file: mailFile
173
- // });
174
-
175
- // // we need to insert a copy into database...
176
- // // with recipient
177
- // db.emails.add({
178
- // originalFile,
179
- // textBody: s.text,
180
- // // htmlBody: s.html,
181
- // subject: email.subject,
182
- // senderID: activity.mailboxID,
183
- // headerMessageID: email.headerMessageID,
184
- // senderName: email.senderName || senderName,
185
- // recipients: [db.emailRecipients.add({
186
- // emailAddressID: activity.emailAddressID,
187
- // type: "to"
188
- // })],
189
- // attachments: email.attachments?.map((x) => db.appFiles.add({
190
- // ... x,
191
- // appFileID: void 0
192
- // })),
193
- // status: "received",
194
- // received: true,
195
- // dateSent: now,
196
- // dateReceived: now,
197
- // dateCreated: now,
198
- // mailboxes: [
199
- // db.mailboxEmails.add({
200
- // mailboxID: activity.emailAddressID
201
- // })
202
- // ]
203
- // });
204
- // db.raiseEvents = true;
205
- // db.verifyFilters = false;
206
- // await db.saveChanges();
207
- // return {
208
- // statusCode: SmtpStatusCodes.Ok,
209
- // logs: "Delivered"
210
- // } as ISmtpResponse;
211
-
212
- // }
213
-
214
- // const host = activity.subscriber.domain.name;
215
- // await using client = await smtpPool.acquire(host);
216
- // const status = await client.send({
217
- // from: senderEmail,
218
- // to: [to],
219
- // host
220
- // }, mailFile);
221
-
222
- // if (Number(status.statusCode) >= 400) {
223
- // Tracer.instance.error(status.logs, {
224
- // path: to,
225
- // host
226
- // });
227
- // }
228
-
229
- // return status;
230
- // }
231
-
232
- // @UniqueActivity
233
- // async saveStatus(
234
- // @Inject db?: SocialMailContext,
235
- // @Inject els?: EmailLogService
236
- // ) {
237
- // const { emailID, emailAddressID: subscriberID, mailboxID } = this.input;
238
- // db.verifyFilters = false;
239
- // const activity = this.response?.statusCode === SmtpStatusCodes.Ok
240
- // ? "sent"
241
- // : "failed";
242
- // await db.subscriberActivities.saveDirect({
243
- // mode: "insert",
244
- // changes: {
245
- // mailboxID,
246
- // emailID,
247
- // emailAddressID: subscriberID,
248
- // activity,
249
- // dateCreated: DateTime.now
250
- // }
251
- // });
252
- // await els.saveText(this.input.emailID, this.input.activityID.toString(), this.response.logs);
253
- // return;
254
-
255
- // }
256
-
257
- // }