feat(email): add persistent smartmta storage and runtime-managed email domain syncing
This commit is contained in:
@@ -530,13 +530,49 @@ export class StatsHandler {
|
||||
nextRetry?: number;
|
||||
}>;
|
||||
}> {
|
||||
// TODO: Implement actual queue status collection
|
||||
const emailServer = this.opsServerRef.dcRouterRef.emailServer;
|
||||
if (!emailServer) {
|
||||
return {
|
||||
pending: 0,
|
||||
active: 0,
|
||||
failed: 0,
|
||||
retrying: 0,
|
||||
items: [],
|
||||
};
|
||||
}
|
||||
|
||||
const queueStats = emailServer.getQueueStats();
|
||||
const items = emailServer.getQueueItems()
|
||||
.sort((a, b) => {
|
||||
const left = a.createdAt instanceof Date ? a.createdAt.getTime() : new Date(a.createdAt).getTime();
|
||||
const right = b.createdAt instanceof Date ? b.createdAt.getTime() : new Date(b.createdAt).getTime();
|
||||
return right - left;
|
||||
})
|
||||
.slice(0, 50)
|
||||
.map((item) => {
|
||||
const emailLike = item.processingResult;
|
||||
const recipients = Array.isArray(emailLike?.to)
|
||||
? emailLike.to
|
||||
: Array.isArray(emailLike?.email?.to)
|
||||
? emailLike.email.to
|
||||
: [];
|
||||
const subject = emailLike?.subject || emailLike?.email?.subject || '';
|
||||
return {
|
||||
id: item.id,
|
||||
recipient: recipients[0] || '',
|
||||
subject,
|
||||
status: item.status,
|
||||
attempts: item.attempts,
|
||||
nextRetry: item.nextAttempt instanceof Date ? item.nextAttempt.getTime() : undefined,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
pending: 0,
|
||||
active: 0,
|
||||
failed: 0,
|
||||
retrying: 0,
|
||||
items: [],
|
||||
pending: queueStats.status.pending,
|
||||
active: queueStats.status.processing,
|
||||
failed: queueStats.status.failed,
|
||||
retrying: queueStats.status.deferred,
|
||||
items,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -600,4 +636,4 @@ export class StatsHandler {
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user