Add new webhook when SMS fail to send

This commit is contained in:
Niels Boussion 2021-04-14 12:11:50 +02:00
parent b8e587a59e
commit c3fb8be0ad
5 changed files with 43 additions and 1 deletions

View file

@ -187,7 +187,18 @@ namespace controllers\internals;
$return['error'] = true;
$return['error_message'] = $response['error_message'];
$status = \models\Sended::STATUS_FAILED;
$this->create($id_user, $id_phone, $at, $text, $destination, $response['uid'] ?? uniqid(), $adapter->meta_classname(), $flash, $status);
$errored_id = $this->create($id_user, $id_phone, $at, $text, $destination, $response['uid'] ?? uniqid()$
$errored = [
'id' => $errored_id,
'at' => $at,
'text' => $text,
'destination' => $destination,
'origin' => $id_phone,
];
$internal_webhook = new Webhook($this->bdd);
$internal_webhook->trigger($id_user, \models\Webhook::TYPE_SEND_ERROR, $errored);
return $return;
}