@astralibx/email-account-manager 10.1.0 → 10.2.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 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", {