payload-plugin-newsletter 0.16.7 → 0.16.8

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
@@ -3188,6 +3188,9 @@ var EMAIL_SAFE_CONFIG = {
3188
3188
  FORBID_ATTR: ["class", "id", "onclick", "onload", "onerror"]
3189
3189
  };
3190
3190
  async function convertToEmailSafeHtml(editorState, options) {
3191
+ if (!editorState) {
3192
+ return "";
3193
+ }
3191
3194
  const rawHtml = await lexicalToEmailHtml(editorState, options?.mediaUrl);
3192
3195
  const sanitizedHtml = import_isomorphic_dompurify2.default.sanitize(rawHtml, EMAIL_SAFE_CONFIG);
3193
3196
  if (options?.wrapInTemplate) {
@@ -4394,6 +4397,10 @@ var createBroadcastsCollection = (pluginConfig) => {
4394
4397
  async ({ doc, operation, req, previousDoc }) => {
4395
4398
  if (!hasProviders) return doc;
4396
4399
  if (operation === "create") {
4400
+ if (!doc.subject || !doc.contentSection?.content) {
4401
+ req.payload.logger.info("Skipping provider sync - broadcast has no subject or content yet");
4402
+ return doc;
4403
+ }
4397
4404
  try {
4398
4405
  const providerConfig = await getBroadcastConfig(req, pluginConfig);
4399
4406
  if (!providerConfig || !providerConfig.token) {
@@ -4404,6 +4411,10 @@ var createBroadcastsCollection = (pluginConfig) => {
4404
4411
  const provider = new BroadcastApiProvider2(providerConfig);
4405
4412
  req.payload.logger.info("Converting content to HTML...");
4406
4413
  const htmlContent = await convertToEmailSafeHtml(doc.contentSection?.content);
4414
+ if (!htmlContent || htmlContent.trim() === "") {
4415
+ req.payload.logger.info("Skipping provider sync - content is empty after conversion");
4416
+ return doc;
4417
+ }
4407
4418
  const createData = {
4408
4419
  name: doc.subject,
4409
4420
  // Use subject as name since we removed the name field