@astralibx/email-account-manager 10.0.0 → 10.1.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/index.cjs +46 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.mjs +46 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -1
package/dist/index.cjs
CHANGED
|
@@ -484,7 +484,6 @@ function createEmailIdentifierSchema(options) {
|
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
);
|
|
487
|
-
schema.index({ email: 1 }, { unique: true });
|
|
488
487
|
return schema;
|
|
489
488
|
}
|
|
490
489
|
function createEmailDraftSchema(options) {
|
|
@@ -807,6 +806,9 @@ var IdentifierService = class {
|
|
|
807
806
|
);
|
|
808
807
|
return doc;
|
|
809
808
|
}
|
|
809
|
+
async findById(id) {
|
|
810
|
+
return this.EmailIdentifier.findById(id);
|
|
811
|
+
}
|
|
810
812
|
async findByEmail(email) {
|
|
811
813
|
return this.EmailIdentifier.findOne({ email: email.toLowerCase().trim() });
|
|
812
814
|
}
|
|
@@ -1138,6 +1140,26 @@ var WarmupManager = class {
|
|
|
1138
1140
|
delayRange: phase ? { min: phase.delayMinMs, max: phase.delayMaxMs } : { min: 0, max: 0 }
|
|
1139
1141
|
};
|
|
1140
1142
|
}
|
|
1143
|
+
async advanceAllAccounts() {
|
|
1144
|
+
const accounts = await this.EmailAccount.find({
|
|
1145
|
+
status: ACCOUNT_STATUS.Warmup,
|
|
1146
|
+
"warmup.enabled": true
|
|
1147
|
+
});
|
|
1148
|
+
let advanced = 0;
|
|
1149
|
+
let errors = 0;
|
|
1150
|
+
for (const account of accounts) {
|
|
1151
|
+
try {
|
|
1152
|
+
await this.advanceDay(account._id.toString());
|
|
1153
|
+
advanced++;
|
|
1154
|
+
} catch (err) {
|
|
1155
|
+
errors++;
|
|
1156
|
+
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
1157
|
+
this.logger.error(`Failed to advance warmup for ${account.email}: ${msg}`);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
this.logger.info("Advance all accounts completed", { advanced, errors });
|
|
1161
|
+
return { advanced, errors };
|
|
1162
|
+
}
|
|
1141
1163
|
async updateSchedule(accountId, schedule) {
|
|
1142
1164
|
await this.EmailAccount.findByIdAndUpdate(accountId, {
|
|
1143
1165
|
$set: { "warmup.schedule": schedule }
|
|
@@ -1375,6 +1397,18 @@ var UnsubscribeService = class {
|
|
|
1375
1397
|
</html>`;
|
|
1376
1398
|
}
|
|
1377
1399
|
};
|
|
1400
|
+
function getRedisOptions(redis) {
|
|
1401
|
+
const opts = redis.options;
|
|
1402
|
+
const config = {
|
|
1403
|
+
host: opts.host || "localhost",
|
|
1404
|
+
port: opts.port || 6379,
|
|
1405
|
+
db: opts.db ?? 0
|
|
1406
|
+
};
|
|
1407
|
+
if (opts.username) config.username = opts.username;
|
|
1408
|
+
if (opts.password) config.password = opts.password;
|
|
1409
|
+
if (opts.tls) config.tls = opts.tls;
|
|
1410
|
+
return config;
|
|
1411
|
+
}
|
|
1378
1412
|
var QueueService = class {
|
|
1379
1413
|
constructor(redis, config, settings, logger) {
|
|
1380
1414
|
this.redis = redis;
|
|
@@ -1392,20 +1426,20 @@ var QueueService = class {
|
|
|
1392
1426
|
const approvalQueueName = this.config.options?.queues?.approvalQueueName || "email-approved";
|
|
1393
1427
|
const globalSettings = await this.settings.get();
|
|
1394
1428
|
const queueSettings = globalSettings.queues;
|
|
1395
|
-
const
|
|
1429
|
+
const connectionOpts = getRedisOptions(this.redis);
|
|
1396
1430
|
this.sendQueue = new bullmq.Queue(sendQueueName, {
|
|
1397
|
-
connection:
|
|
1431
|
+
connection: connectionOpts,
|
|
1398
1432
|
prefix: keyPrefix
|
|
1399
1433
|
});
|
|
1400
1434
|
this.approvalQueue = new bullmq.Queue(approvalQueueName, {
|
|
1401
|
-
connection:
|
|
1435
|
+
connection: connectionOpts,
|
|
1402
1436
|
prefix: keyPrefix
|
|
1403
1437
|
});
|
|
1404
1438
|
this.sendWorker = new bullmq.Worker(
|
|
1405
1439
|
sendQueueName,
|
|
1406
1440
|
processors.sendProcessor,
|
|
1407
1441
|
{
|
|
1408
|
-
connection:
|
|
1442
|
+
connection: connectionOpts,
|
|
1409
1443
|
prefix: keyPrefix,
|
|
1410
1444
|
concurrency: queueSettings.sendConcurrency
|
|
1411
1445
|
}
|
|
@@ -1414,7 +1448,7 @@ var QueueService = class {
|
|
|
1414
1448
|
approvalQueueName,
|
|
1415
1449
|
processors.approvalProcessor,
|
|
1416
1450
|
{
|
|
1417
|
-
connection:
|
|
1451
|
+
connection: connectionOpts,
|
|
1418
1452
|
prefix: keyPrefix,
|
|
1419
1453
|
concurrency: queueSettings.approvalConcurrency
|
|
1420
1454
|
}
|
|
@@ -2955,11 +2989,13 @@ function createEmailAccountManager(config) {
|
|
|
2955
2989
|
error: err instanceof Error ? err.message : "Unknown error"
|
|
2956
2990
|
});
|
|
2957
2991
|
});
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
error
|
|
2992
|
+
if (config.options?.imap?.autoStart !== false) {
|
|
2993
|
+
imapBounceChecker.start().catch((err) => {
|
|
2994
|
+
logger.error("Failed to start IMAP bounce checker", {
|
|
2995
|
+
error: err instanceof Error ? err.message : "Unknown error"
|
|
2996
|
+
});
|
|
2961
2997
|
});
|
|
2962
|
-
}
|
|
2998
|
+
}
|
|
2963
2999
|
const accountController = createAccountController(
|
|
2964
3000
|
EmailAccount,
|
|
2965
3001
|
capacityManager,
|