Iām integrating phpList 3.3.7 into a web shop using the Rest API.
I noticed that the subscriberDelete function only removes the specified user, not user_history etc.
The same applies to restapi2.
This is my fix (/lists/admin/plugins/restapi/includes/subscribers.php):
public static function subscriberDelete()
{
//$sql = 'DELETE FROM '.$GLOBALS['tables']['user'].' WHERE id=:id;';
try {
if (!is_numeric($_REQUEST['id'])) {
Response::outputErrorMessage('invalid call');
}
//$db = PDO::getConnection();
//$stmt = $db->prepare($sql);
//$stmt->bindParam('id', $_REQUEST['id'], PDO::PARAM_INT);
//$stmt->execute();
deleteUserIncludeBlacklist($_REQUEST['id']);
//$db = null;
Response::outputDeleted('Subscriber', sprintf('%d',$_REQUEST['id']));
} catch (\Exception $e) {
Response::outputError($e);
}
}
The sql is replaced with the available deleteUserIncludeBlacklist function.
It looks like youāve modified the old REST API which is unmaintained, so using it in production may have security issues (nobody is monitoring that)
Be careful with the deleteUserIncludeBlacklist function, as I recall it explicitly does not retain blacklist data, which means blacklisted subs can be Reimported or maliciously resubscribed. GDPR allows retaining a blacklist by my understanding, so thatās not an issue.
Thanks for warnings. Iām not in production yet. To me it looks like restapi2 is not quite production capable either.
Iāve done all I can to harden the Rest API. I use these settings:
Require SSL on Rest API calls: yes
IP Address that is allowed to access the API: my Web Shop server ip address
Require the secret code for Rest API calls: yes
Iāve also added quite comprehensive error logging into the Rest API Client, as well as modal dialogs showing limited error information to customers (and to my self, when testing).
No subscriber will be automatically confirmed. New subscribers get the standard email message asking for confirmation.
The phpList integration is inserted into the Web Shop as follows:
Customers purchasing without an account
During the checkout, when they enter their email, I notify if they havenāt subcribed or confirmed. In the first case they are offered an option to subscribe. In the latter case, they are offered an option to resubscribe (e.g. if they donāt have the previous message asking for confirmation any more).
If they resubscribe, I simply delete the unconfirmed subscriber with the subscriberDelete function and add a new one. This ensures that the message asking for confirmation is sent.
Customers registering an account
The procedure is basically the same as in #1.
Registered customers changing the details
Customers can subscribe/unsubscribe a newsletter. In the latter case I use the subscriberDelete function.
Restapi2 misses the subscribe function. Also, the are no sendMail calls, like in the version I use. Any plans to add these?
It would also be nice to optionally send an email when unsubscribing using the Rest API.
Please add user cleanup also to restapi2:).
Iām not sure about GDPR and blacklisted subscribers. The tables user_blacklist and user_blacklist_data contain their email addresses.
As I pointed out in my first message, If a subscriber is deleted via Rest API, we should also remove user history, etc. Otherwise there will be a lot orphan table rows in the db. I believe that those cannot be seen in admin.
The standard functions used in phpList 3 for removing subscribers should be sufficient. If some of them leave behind so data it is possibly in order to avoid ārewriting statistical historyā and retrospectively changing data about campaigns that were already delivered.
The standard Rest API subscriberDelete only removes the user record, as seen above. Other user related data remain in the db and cannot be seen in the admin interface, because the primary record is gone.
That is why I replaced the standard code with deleteUserIncludeBlacklist.