Check for empty events before proceeding with the syncing (#531).

This commit is contained in:
Alex Tselegidis 2020-03-10 20:39:53 +01:00
parent 902485e2d3
commit 673ec82aa3

View file

@ -221,8 +221,11 @@ class Google extends CI_Controller {
foreach ($events->getItems() as $event)
{
$results = $this->appointments_model->get_batch(['id_google_calendar' => $event->getId()]);
if (count($results) == 0)
{
if (!empty($results) || empty($event)) {
continue;
}
// Record doesn't exist in E!A, so add the event now.
$appointment = [
'start_datetime' => date('Y-m-d H:i:s', strtotime($event->start->getDateTime())),
@ -238,7 +241,6 @@ class Google extends CI_Controller {
$this->appointments_model->add($appointment);
}
}
$this->output
->set_content_type('application/json')