Commit a88561ca authored by Romain Thouvenin's avatar Romain Thouvenin
Browse files

Finer sieve for tracking errors that can be ignored

parent 9c57d89e
......@@ -20,12 +20,19 @@ function civicrm_api3_traxy_Ignoreknownerrors($params) {
return civicrm_api3_create_success();
}
$max_qid = CRM_Core_DAO::executeQuery("SELECT FLOOR(MAX(id) * 1.1) FROM civicrm_mailing_event_queue")->fetchValue();
$max_qid = CRM_Core_DAO::executeQuery("SELECT MAX(id) FROM civicrm_mailing_event_queue")->fetchValue();
if ($queue_id > $max_qid) {
//This is probably someone trying some random value of queue id
return civicrm_api3_create_success();
}
$params = [ 1 => [$queue_id, 'Integer'], 2 => [CRM_Utils_Date::processDate($json_msg->timestamp), 'String'] ];
$deliver_date = CRM_Core_DAO::executeQuery("SELECT time_stamp FROM civicrm_mailing_event_delivered WHERE event_queue_id = %1 AND time_stamp <= %2", $params)->fetchValue();
if (!$deliver_date) {
//Someone pretends they received a mailing before it was sent...
return civicrm_api3_create_success();
}
if (isset($json_msg->params->u)) {
//Same as for queue id
$url_id = $json_msg->params->u;
......@@ -33,10 +40,19 @@ function civicrm_api3_traxy_Ignoreknownerrors($params) {
return civicrm_api3_create_success();
}
$max_uid = CRM_Core_DAO::executeQuery("SELECT FLOOR(MAX(id) * 1.1) FROM civicrm_mailing_trackable_url")->fetchValue();
$max_uid = CRM_Core_DAO::executeQuery("SELECT MAX(id) FROM civicrm_mailing_trackable_url")->fetchValue();
if ($url_id > $max_uid) {
return civicrm_api3_create_success();
}
$params = [ 1 => [$url_id, 'Integer'], 2 => [CRM_Utils_Date::processDate($json_msg->timestamp), 'String'] ];
$deliver_date = CRM_Core_DAO::executeQuery(
"SELECT scheduled_date FROM civicrm_mailing m JOIN civicrm_mailing_trackable_url u ON u.mailing_id = m.id WHERE u.id = %1 AND scheduled_date < %2",
$params
)->fetchValue();
if (!$deliver_date) {
return civicrm_api3_create_success();
}
}
return civicrm_api3_create_error("The message cannot be ignored", ['retry_later' => FALSE]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment