X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Freceive.php;h=db1287ea6f1f804a8b6b784710ce5e01409beb07;hb=708ffaff51d3f5112af6b1fbd25d7ff6391e496e;hp=80be7d2a2957edb1fdc0b7820efe64ec60952301;hpb=71ec84f6dc83f753fe80170cfdfd32d202850d90;p=friendica.git diff --git a/mod/receive.php b/mod/receive.php index 80be7d2a29..db1287ea6f 100644 --- a/mod/receive.php +++ b/mod/receive.php @@ -6,20 +6,23 @@ use Friendica\App; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Protocol\Diaspora; /** - * @param object $a App + * @param App $a App * @return void + * @throws ImagickException + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ function receive_post(App $a) { $enabled = intval(Config::get('system', 'diaspora_enabled')); if (!$enabled) { - logger('mod-diaspora: disabled'); - System::httpExit(500); + Logger::log('mod-diaspora: disabled'); + throw new \Friendica\Network\HTTPException\InternalServerErrorException(); } if (($a->argc == 2) && ($a->argv[1] === 'public')) { @@ -29,49 +32,49 @@ function receive_post(App $a) $public = false; if ($a->argc != 3 || $a->argv[1] !== 'users') { - System::httpExit(500); + throw new \Friendica\Network\HTTPException\InternalServerErrorException(); } $guid = $a->argv[2]; $importer = DBA::selectFirst('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]); if (!DBA::isResult($importer)) { - System::httpExit(500); + throw new \Friendica\Network\HTTPException\InternalServerErrorException(); } } // It is an application/x-www-form-urlencoded - logger('mod-diaspora: receiving post', LOGGER_DEBUG); + Logger::log('mod-diaspora: receiving post', Logger::DEBUG); if (empty($_POST['xml'])) { $postdata = file_get_contents("php://input"); if ($postdata == '') { - System::httpExit(500); + throw new \Friendica\Network\HTTPException\InternalServerErrorException(); } - logger('mod-diaspora: message is in the new format', LOGGER_DEBUG); + Logger::log('mod-diaspora: message is in the new format', Logger::DEBUG); $msg = Diaspora::decodeRaw($importer, $postdata); } else { $xml = urldecode($_POST['xml']); - logger('mod-diaspora: decode message in the old format', LOGGER_DEBUG); + Logger::log('mod-diaspora: decode message in the old format', Logger::DEBUG); $msg = Diaspora::decode($importer, $xml); if ($public && !$msg) { - logger('mod-diaspora: decode message in the new format', LOGGER_DEBUG); + Logger::log('mod-diaspora: decode message in the new format', Logger::DEBUG); $msg = Diaspora::decodeRaw($importer, $xml); } } - logger('mod-diaspora: decoded', LOGGER_DEBUG); + Logger::log('mod-diaspora: decoded', Logger::DEBUG); - logger('mod-diaspora: decoded msg: ' . print_r($msg, true), LOGGER_DATA); + Logger::log('mod-diaspora: decoded msg: ' . print_r($msg, true), Logger::DATA); if (!is_array($msg)) { - System::httpExit(500); + throw new \Friendica\Network\HTTPException\InternalServerErrorException(); } - logger('mod-diaspora: dispatching', LOGGER_DEBUG); + Logger::log('mod-diaspora: dispatching', Logger::DEBUG); $ret = true; if ($public) { @@ -80,6 +83,9 @@ function receive_post(App $a) $ret = Diaspora::dispatch($importer, $msg); } - System::httpExit(($ret) ? 200 : 500); - // NOTREACHED + if ($ret) { + throw new \Friendica\Network\HTTPException\OKException(); + } else { + throw new \Friendica\Network\HTTPException\InternalServerErrorException(); + } }