diff --git a/build/api/module/message.php b/build/api/module/message.php index 2100491..8134025 100644 --- a/build/api/module/message.php +++ b/build/api/module/message.php @@ -89,19 +89,31 @@ class message public function DELETE_emergency($argv){ extract($argv); + /* (1) Create emergenct + ---------------------------------------------------------*/ + /* (1) Try to create entry */ + $deleted = Repo::request('emergency', 'remove', $id); + + /* (2) If cannot create -> dispatch error */ + if( $deleted === false ) + return ['error' => new Error(Err::RepoError)]; + + + + /* (2) Send to WebSocket + ---------------------------------------------------------*/ $wsi = new wsinterop("localhost",9998); $wsi->send([ - "operation" => "DelMessage", - "id" => $id, - "channelType" => "Emergency", - "channelName" => is_null($URL_0) ? "" : "$URL_0" + 'operation' => 'DelMessage', + 'id' => $id, + 'channelType' => 'Emergency', + 'channelName' => "$URL_0" ]); $wsi->close(); - return ["sent" => true]; - //TODO: tout poster dans la BDD + return ["deleted" => true]; } public function PUT_emergency($argv){