1
1
Fork 0

Replace System::httpExit() by HTTPException throwing

This commit is contained in:
Hypolite Petovan 2019-05-01 23:16:10 -04:00
commit 41f781c52a
39 changed files with 116 additions and 140 deletions

View file

@ -28,7 +28,7 @@ function salmon_post(App $a, $xml = '') {
DBA::escape($nick)
);
if (! DBA::isResult($r)) {
System::httpExit(500);
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
$importer = $r[0];
@ -49,7 +49,7 @@ function salmon_post(App $a, $xml = '') {
if (empty($base)) {
Logger::log('unable to locate salmon data in xml ');
System::httpExit(400);
throw new \Friendica\Network\HTTPException\BadRequestException();
}
// Stash the signature away for now. We have to find their key or it won't be good for anything.
@ -87,7 +87,7 @@ function salmon_post(App $a, $xml = '') {
if(! $author_link) {
Logger::log('Could not retrieve author URI.');
System::httpExit(400);
throw new \Friendica\Network\HTTPException\BadRequestException();
}
// Once we have the author URI, go to the web and try to find their public key
@ -98,7 +98,7 @@ function salmon_post(App $a, $xml = '') {
if(! $key) {
Logger::log('Could not retrieve author key.');
System::httpExit(400);
throw new \Friendica\Network\HTTPException\BadRequestException();
}
$key_info = explode('.',$key);
@ -130,7 +130,7 @@ function salmon_post(App $a, $xml = '') {
if (! $verify) {
Logger::log('Message did not verify. Discarding.');
System::httpExit(400);
throw new \Friendica\Network\HTTPException\BadRequestException();
}
Logger::log('Message verified with mode '.$mode);
@ -177,8 +177,7 @@ function salmon_post(App $a, $xml = '') {
//if((DBA::isResult($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == Contact::FOLLOWER) || ($r[0]['blocked']))) {
if (DBA::isResult($r) && $r[0]['blocked']) {
Logger::log('Ignoring this author.');
System::httpExit(202);
// NOTREACHED
throw new \Friendica\Network\HTTPException\AcceptedException();
}
// Placeholder for hub discovery.
@ -188,5 +187,5 @@ function salmon_post(App $a, $xml = '') {
OStatus::import($data, $importer, $contact_rec, $hub);
System::httpExit(200);
throw new \Friendica\Network\HTTPException\OKException();
}