@astralibx/email-account-manager 10.1.0 → 10.3.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 +20 -0
- package/dist/index.cjs +11 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +11 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,6 +114,26 @@ Advanced: [Capacity Selection](https://github.com/Hariprakash1997/astralib/blob/
|
|
|
114
114
|
|
|
115
115
|
> **Important:** The warmup system requires calling `advanceDay()` daily via cron job. Without this, accounts stay in warmup indefinitely.
|
|
116
116
|
|
|
117
|
+
### Redis Key Prefix (Required for Multi-Project Deployments)
|
|
118
|
+
|
|
119
|
+
> **WARNING:** If multiple projects share the same Redis server, you MUST set a unique `keyPrefix` per project. Without this, BullMQ queues will collide — Project A's worker could process Project B's emails.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
const eam = createEmailAccountManager({
|
|
123
|
+
redis: {
|
|
124
|
+
connection: redis,
|
|
125
|
+
keyPrefix: 'myproject-eam:', // REQUIRED if sharing Redis
|
|
126
|
+
},
|
|
127
|
+
// ...
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
| Default | Risk |
|
|
132
|
+
|---------|------|
|
|
133
|
+
| `'eam:'` | Two projects using defaults share the same `eam:email-send` and `eam:email-approved` queues |
|
|
134
|
+
|
|
135
|
+
**Always set a unique prefix** like `projectname-eam:` or `projectname:`.
|
|
136
|
+
|
|
117
137
|
## Security Notes
|
|
118
138
|
|
|
119
139
|
**Credential storage**: SMTP and IMAP passwords (`smtp.pass`, `imap.pass`) are stored as plaintext in MongoDB. You should encrypt these values at the application layer before passing them to this library, and decrypt them after retrieval. A built-in encryption layer is planned for a future version.
|
package/dist/index.cjs
CHANGED
|
@@ -505,6 +505,8 @@ function createEmailDraftSchema(options) {
|
|
|
505
505
|
sentAt: Date,
|
|
506
506
|
scheduledAt: Date,
|
|
507
507
|
failureReason: String,
|
|
508
|
+
source: { type: String },
|
|
509
|
+
identifierId: { type: String },
|
|
508
510
|
metadata: { type: mongoose.Schema.Types.Mixed }
|
|
509
511
|
},
|
|
510
512
|
{
|
|
@@ -1694,7 +1696,8 @@ var ApprovalService = class {
|
|
|
1694
1696
|
this.hooks?.onDraftApproved?.({
|
|
1695
1697
|
draftId,
|
|
1696
1698
|
to: draft.to,
|
|
1697
|
-
scheduledAt
|
|
1699
|
+
scheduledAt,
|
|
1700
|
+
draft: draft.toObject()
|
|
1698
1701
|
});
|
|
1699
1702
|
}
|
|
1700
1703
|
async reject(draftId, reason) {
|
|
@@ -2212,7 +2215,7 @@ function createSendProcessor(smtpService, logger) {
|
|
|
2212
2215
|
}
|
|
2213
2216
|
|
|
2214
2217
|
// src/queues/approval.queue.ts
|
|
2215
|
-
function createApprovalProcessor(EmailDraft, smtpService, queueService, logger) {
|
|
2218
|
+
function createApprovalProcessor(EmailDraft, smtpService, queueService, logger, identifierService) {
|
|
2216
2219
|
return async (job) => {
|
|
2217
2220
|
const { draftId } = job.data;
|
|
2218
2221
|
const draft = await EmailDraft.findById(draftId);
|
|
@@ -2236,6 +2239,10 @@ function createApprovalProcessor(EmailDraft, smtpService, queueService, logger)
|
|
|
2236
2239
|
html: d.htmlBody,
|
|
2237
2240
|
text: d.textBody || ""
|
|
2238
2241
|
});
|
|
2242
|
+
if (d.identifierId && identifierService) {
|
|
2243
|
+
await identifierService.incrementSentCount(d.to);
|
|
2244
|
+
logger.info("Identifier sentCount incremented for draft", { draftId, to: d.to, identifierId: d.identifierId });
|
|
2245
|
+
}
|
|
2239
2246
|
};
|
|
2240
2247
|
}
|
|
2241
2248
|
|
|
@@ -2982,7 +2989,8 @@ function createEmailAccountManager(config) {
|
|
|
2982
2989
|
EmailDraft,
|
|
2983
2990
|
smtpService,
|
|
2984
2991
|
queueService,
|
|
2985
|
-
logger
|
|
2992
|
+
logger,
|
|
2993
|
+
identifierService
|
|
2986
2994
|
);
|
|
2987
2995
|
queueService.init({ sendProcessor, approvalProcessor }).catch((err) => {
|
|
2988
2996
|
logger.error("Failed to initialize queues", {
|