responsiv / campaign-plugin

[PREMIUM] Send professional campaign messages to your subscribers.
http://octobercms.com/plugin/responsiv-campaign
5 stars 2 forks source link

Unsubscribed subscribers being added to new campaigns #54

Closed developerabdd closed 2 years ago

developerabdd commented 5 years ago

When sending a new campaign and selecting a given list, all subscribers from that list are being added to the campaign, regardless of them having previously unsubscribed.

In $\responsiv\campaign\classes\CampaignManager.php, lines 150-155 there is the following:

foreach ($campaign->subscriber_lists as $list) {
    $ids = $list->subscribers()->lists( 'id' );
    if ($ids && count($ids) > 0) {
        $campaign->subscribers()->sync($ids, false);
    }
}

I suspect it should actually be something like the following:

foreach ($campaign->subscriber_lists as $list) {
    $ids = $list->subscribers()->whereNull( 'unsubscribed_at' )->lists( 'id' );
    if ($ids && count($ids) > 0) {
        $campaign->subscribers()->sync($ids, false);
    }
}
daftspunk commented 2 years ago

Thanks for this, I suspect it is OK since unsubscribed_at subscribers are never sent anything. So they are added to the list for no reason.

Nonetheless, we've added this code for the next release. Thanks!