diff --git a/inc/mqtthandler.class.php b/inc/mqtthandler.class.php index 18ac40c3..55e78283 100644 --- a/inc/mqtthandler.class.php +++ b/inc/mqtthandler.class.php @@ -322,9 +322,10 @@ protected function updateTaskStatus($topic, $message) { } // Get the current status of the task for the agent + $taskStatus = new PluginFlyvemdmTaskStatus(); $request = [ 'AND' => [ - PluginFlyvemdmAgent::getForeignKeyField() => $agentId, + PluginFlyvemdmAgent::getForeignKeyField() => $agent->getID(), PluginFlyvemdmTask::getForeignKeyField() => $taskId ] ]; @@ -335,7 +336,7 @@ protected function updateTaskStatus($topic, $message) { // Update the task $policyFactory = new PluginFlyvemdmPolicyFactory(); $policy = $policyFactory->createFromDBByID($task->getField('plugin_flyvemdm_policies_id')); - $taskStatus->updateStatus($policy, $status); + $taskStatus->updateStatus($policy, $feedback['status']); $this->updateLastContact($topic, '!'); } diff --git a/inc/task.class.php b/inc/task.class.php index 318359ce..86cc4029 100644 --- a/inc/task.class.php +++ b/inc/task.class.php @@ -322,6 +322,7 @@ public function post_addItem() { public function post_updateItem($history = 1) { $this->publishPolicy($this->notifiable); + $this->deleteTaskStatuses(); $this->createTaskStatuses($this->notifiable); }