Commit 1d6626d7 authored by Romain Thouvenin's avatar Romain Thouvenin
Browse files

API function to consume tracked opens from Traxy

parent 995c1630
<?php
use CRM_Traxivi_ExtensionUtil as E;
function _civicrm_api3_traxy_Trackopen_spec(&$spec) {
$spec['message']['api.required'] = 1;
}
/**
* Rabbitizen consumer to record a tracked open coming from Traxy
*/
function civicrm_api3_traxy_Trackopen($params) {
$eq = CRM_Utils_Type::escape(CRM_Mailing_Event_BAO_Queue::getTableName(), 'MysqlColumnNameOrAlias');
$json_msg = json_decode($params['message']);
$queue_id = $json_msg->params->q;
$q = new CRM_Mailing_Event_BAO_Queue();
$q->id = $queue_id;
if ($q->find(TRUE)) {
$oe = new CRM_Mailing_Event_BAO_Opened();
$oe->event_queue_id = $queue_id;
$oe->time_stamp = CRM_Utils_Date::processDate($json_msg->timestamp);
$oe->save();
return civicrm_api3_create_success();
}
return civicrm_api3_create_error("The queue id $queue_id does not exist", ['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