payload-plugin-newsletter 0.25.2 → 0.25.4

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.
@@ -1838,6 +1838,10 @@ async function populateBlockMediaFields(node, payload, config) {
1838
1838
  }
1839
1839
  }
1840
1840
  }
1841
+ if (field.type === "richText" && node.fields[field.name]) {
1842
+ await populateRichTextUploads(node.fields[field.name], payload);
1843
+ payload.logger?.info(`Processed rich text field ${field.name} for upload nodes`);
1844
+ }
1841
1845
  }
1842
1846
  }
1843
1847
  }
@@ -1847,6 +1851,46 @@ async function populateBlockMediaFields(node, payload, config) {
1847
1851
  }
1848
1852
  }
1849
1853
  }
1854
+ async function populateRichTextUploads(content, payload) {
1855
+ if (!content || typeof content !== "object") return;
1856
+ if (content.root?.children) {
1857
+ await processNodeArray(content.root.children);
1858
+ }
1859
+ if (Array.isArray(content)) {
1860
+ await processNodeArray(content);
1861
+ }
1862
+ async function processNodeArray(nodes) {
1863
+ await Promise.all(nodes.map(processNode));
1864
+ }
1865
+ async function processNode(node) {
1866
+ if (!node || typeof node !== "object") return;
1867
+ if (node.type === "upload" && node.relationTo === "media" && typeof node.value === "string" && node.value.match(/^[a-f0-9]{24}$/i)) {
1868
+ try {
1869
+ const media = await payload.findByID({
1870
+ collection: "media",
1871
+ id: node.value,
1872
+ depth: 0
1873
+ });
1874
+ if (media) {
1875
+ node.value = media;
1876
+ payload.logger?.info(`Populated rich text upload node:`, {
1877
+ mediaId: node.value,
1878
+ mediaUrl: media.url,
1879
+ filename: media.filename
1880
+ });
1881
+ }
1882
+ } catch (error) {
1883
+ payload.logger?.error(`Failed to populate rich text upload ${node.value}:`, error);
1884
+ }
1885
+ }
1886
+ if (node.children && Array.isArray(node.children)) {
1887
+ await processNodeArray(node.children);
1888
+ }
1889
+ if (node.root?.children && Array.isArray(node.root.children)) {
1890
+ await processNodeArray(node.root.children);
1891
+ }
1892
+ }
1893
+ }
1850
1894
  var createBroadcastPreviewEndpoint = (config, _collectionSlug) => {
1851
1895
  return {
1852
1896
  path: "/preview",
@@ -2277,6 +2321,8 @@ var createBroadcastsCollection = (pluginConfig) => {
2277
2321
  id: doc.id,
2278
2322
  data: {
2279
2323
  providerId: providerBroadcast.id,
2324
+ externalId: providerBroadcast.id,
2325
+ // Set externalId to match providerId for webhook lookup
2280
2326
  providerData: providerBroadcast.providerData
2281
2327
  },
2282
2328
  req
@@ -2285,6 +2331,8 @@ var createBroadcastsCollection = (pluginConfig) => {
2285
2331
  return {
2286
2332
  ...doc,
2287
2333
  providerId: providerBroadcast.id,
2334
+ externalId: providerBroadcast.id,
2335
+ // Include externalId in return value
2288
2336
  providerData: providerBroadcast.providerData
2289
2337
  };
2290
2338
  } catch (error) {