Schedules welcome notification when adding/editing subscriber

This commit is contained in:
Vlad
2017-12-18 19:44:09 -05:00
parent f616ef4d6c
commit 5d5b61b76f
4 changed files with 91 additions and 7 deletions

View File

@ -10,6 +10,7 @@ use MailPoet\Form\Util\FieldNameObfuscator;
use MailPoet\Models\Form;
use MailPoet\Models\StatisticsForms;
use MailPoet\Models\Subscriber;
use MailPoet\Newsletter\Scheduler\Scheduler;
use MailPoet\Segments\SubscribersListings;
use MailPoet\Subscription\Throttling as SubscriptionThrottling;
use MailPoet\WP\Hooks;
@ -158,11 +159,15 @@ class Subscribers extends APIEndpoint {
if(!empty($errors)) {
return $this->badRequest($errors);
} else {
return $this->successResponse(
Subscriber::findOne($subscriber->id)->asArray()
);
}
if(!empty($data['segments'])) {
Scheduler::scheduleSubscriberWelcomeNotification($subscriber->id, $data['segments']);
}
return $this->successResponse(
Subscriber::findOne($subscriber->id)->asArray()
);
}
function restore($data = array()) {