X-Git-Url: https://git.cweiske.de/anoweco.git/blobdiff_plain/fd760dceff0278836fd05fd4bd314218dc33db34..ca522c29a1cc10f665130d21d45ede99ddaa8ac7:/www/micropub.php diff --git a/www/micropub.php b/www/micropub.php index 9d91272..e028782 100644 --- a/www/micropub.php +++ b/www/micropub.php @@ -82,24 +82,29 @@ function handleCreate($json, $token) ); } - if (!isset($json->properties->{'in-reply-to'})) { - mpError( - 'HTTP/1.0 400 Bad Request', - 'invalid_request', - 'Only replies accepted' - ); - } - $storage = new Storage(); + $lb = new Linkback(); try { $id = $storage->addComment($json, $userId); + $lb->ping($id); header('HTTP/1.0 201 Created'); header('Location: ' . Urls::full(Urls::comment($id))); exit(); } catch (\Exception $e) { - //FIXME: return correct status code - header('HTTP/1.0 500 Internal Server Error'); + if ($e->getCode() == 400) { + mpError( + 'HTTP/1.0 400 Bad Request', + 'invalid_request', + $e->getMessage() + ); + } + + mpError( + 'HTTP/1.0 500 Internal Server Error', + 'this_violates_the_spec', + $e->getMessage() + ); exit(); } }