payload-plugin-newsletter 0.24.0 → 0.25.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [0.25.1] - 2025-08-09
2
+
3
+ ### Fixed
4
+ - **Removed webhook status updates**: Eliminated permission errors when processing Broadcast webhooks
5
+ - Webhook handler no longer attempts to update global settings
6
+ - Fixes "Only administrators can modify newsletter settings" errors
7
+
8
+ ### Changed
9
+ - **Webhook subscribers now start as active**: `subscriber.created` webhook events now set status as 'active' instead of 'pending'
10
+ - Better aligns with single opt-in workflows
11
+ - Matches Broadcast's confirmed subscriber status
12
+ - Welcome emails still prevented by `importedFromProvider` flag
13
+
14
+ ## [0.25.0] - 2025-08-08
15
+
16
+ ### Changed
17
+ - **Improved welcome email behavior**: Plugin now properly handles all subscription scenarios
18
+ - New signups via frontend: Send welcome email ✓
19
+ - Resubscriptions via frontend: Send welcome email ✓
20
+ - Webhook imports (new subscribers): No welcome email ✓
21
+ - Webhook reactivations: No welcome email ✓
22
+ - **Resubscription support**: Users who resubscribe through the frontend now receive a "Welcome back" email
23
+ - **Better UX**: Welcome emails now check the `importedFromProvider` flag by default
24
+
25
+ ### Fixed
26
+ - Fixed missing welcome emails for user-initiated resubscriptions
27
+ - Fixed unwanted welcome emails for webhook-imported subscribers
28
+
1
29
  ## [0.24.0] - 2025-08-08
2
30
 
3
31
  ### Added
@@ -3088,7 +3088,7 @@ var createSubscribersCollection = (pluginConfig) => {
3088
3088
  } else {
3089
3089
  console.warn("[Newsletter Plugin] No email service configured for subscriber creation");
3090
3090
  }
3091
- if (doc.subscriptionStatus === "active" && emailService) {
3091
+ if (doc.subscriptionStatus === "active" && emailService && !doc.importedFromProvider) {
3092
3092
  try {
3093
3093
  const settings = await req.payload.findGlobal({
3094
3094
  slug: pluginConfig.settingsSlug || "newsletter-settings"
@@ -3134,6 +3134,30 @@ var createSubscribersCollection = (pluginConfig) => {
3134
3134
  console.warn("[Newsletter Plugin] No email service configured");
3135
3135
  }
3136
3136
  }
3137
+ if (doc.subscriptionStatus === "active" && previousDoc.subscriptionStatus === "unsubscribed" && !doc.importedFromProvider && emailService) {
3138
+ try {
3139
+ const settings = await req.payload.findGlobal({
3140
+ slug: pluginConfig.settingsSlug || "newsletter-settings"
3141
+ });
3142
+ const serverURL = req.payload.config.serverURL || process.env.PAYLOAD_PUBLIC_SERVER_URL || "";
3143
+ const html = await renderEmail("welcome", {
3144
+ email: doc.email,
3145
+ siteName: settings?.brandSettings?.siteName || "Newsletter",
3146
+ preferencesUrl: `${serverURL}/account/preferences`
3147
+ }, pluginConfig);
3148
+ await emailService.send({
3149
+ to: doc.email,
3150
+ subject: settings?.brandSettings?.siteName ? `Welcome back to ${settings.brandSettings.siteName}!` : "Welcome back!",
3151
+ html
3152
+ });
3153
+ console.warn(`Welcome email sent to resubscribed user: ${doc.email}`);
3154
+ } catch (error) {
3155
+ console.error("Failed to send resubscription welcome email:", error);
3156
+ }
3157
+ if (pluginConfig.hooks?.afterSubscribe) {
3158
+ await pluginConfig.hooks.afterSubscribe({ doc, req });
3159
+ }
3160
+ }
3137
3161
  if (doc.subscriptionStatus === "unsubscribed" && previousDoc.subscriptionStatus !== "unsubscribed") {
3138
3162
  doc.unsubscribedAt = (/* @__PURE__ */ new Date()).toISOString();
3139
3163
  if (pluginConfig.hooks?.afterUnsubscribe) {