Merge pull request #67 from xtr-dev/dev

Fix ObjectId casting error when jobs relationship is populated
This commit is contained in:
Bas
2025-10-07 21:38:42 +02:00
committed by GitHub
2 changed files with 6 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@xtr-dev/payload-mailing", "name": "@xtr-dev/payload-mailing",
"version": "0.4.18", "version": "0.4.19",
"description": "Template-based email system with scheduling and job processing for PayloadCMS", "description": "Template-based email system with scheduling and job processing for PayloadCMS",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",

View File

@@ -129,7 +129,11 @@ export async function updateEmailJobRelationship(
id: normalizedEmailId, id: normalizedEmailId,
}) })
const currentJobs = (currentEmail.jobs || []).map((job: any) => String(job)) // Extract IDs from job objects or use the value directly if it's already an ID
// Jobs can be populated (objects with id field) or just IDs (strings/numbers)
const currentJobs = (currentEmail.jobs || []).map((job: any) =>
typeof job === 'object' && job !== null && job.id ? String(job.id) : String(job)
)
const allJobs = [...new Set([...currentJobs, ...normalizedJobIds])] // Deduplicate with normalized strings const allJobs = [...new Set([...currentJobs, ...normalizedJobIds])] // Deduplicate with normalized strings
await payload.update({ await payload.update({