Skip to content

Commit

Permalink
Could not delete a user if this was removed directly on the mailchimp…
Browse files Browse the repository at this point in the history
… site
  • Loading branch information
compojoom committed Aug 10, 2016
1 parent feaa0a2 commit 3de2c81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 8 additions & 4 deletions source/administrator/components/com_cmc/controllers/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function delete()
$api_key = $params->get("api_key", '');
$db = JFactory::getDBO();


if (count($cid))
{
for ($i = 0; $i < count($cid); $i++)
Expand All @@ -63,13 +64,16 @@ public function delete()
}
catch (Exception $e)
{
// Catching the case where the user is already unsubscribed from mailchimp
if ($e->getCode() != 232)
// If we have 404 here, then the user was deleted in mailchimp and we don't need him here
if($e->getCode() == 404)
{
JFactory::getApplication()->enqueueMessage('User seems to be already deleted in the mailchimp list');
}
else
{
throw $e;
JFactory::getApplication()->enqueueMessage($e->getMessage());
}
}

}

$cids = implode(',', $cid);
Expand Down
5 changes: 4 additions & 1 deletion source/administrator/components/com_cmc/helpers/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ public static function unsubscribeList($user)

$api->listUnsubscribe($user->list_id, $user->email, true);


if ($api->getLastError())
{
throw new Exception(JTEXT::_("COM_CMC_UNSUBSCRIBE_FAILED") . ": " . $api->getLastError(), 500);
$response = $api->getLastResponse();

throw new Exception(JTEXT::_("COM_CMC_UNSUBSCRIBE_FAILED") . ": " . $api->getLastError(), $response['headers']['http_code'] );
}

return true;
Expand Down

0 comments on commit 3de2c81

Please sign in to comment.