mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 00:03:23 +00:00
Merge pull request #67 from xtr-dev/dev
Fix ObjectId casting error when jobs relationship is populated
This commit is contained in:
@@ -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",
|
||||||
|
|||||||
@@ -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({
|
||||||
|
|||||||
Reference in New Issue
Block a user