use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Protocol\Diaspora;
+use Friendica\Util\Network;
/**
* @param App $a App
$enabled = intval(Config::get('system', 'diaspora_enabled'));
if (!$enabled) {
Logger::log('mod-diaspora: disabled');
- System::httpExit(500);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
if (($a->argc == 2) && ($a->argv[1] === 'public')) {
$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();
}
}
Logger::log('mod-diaspora: receiving post', Logger::DEBUG);
if (empty($_POST['xml'])) {
- $postdata = file_get_contents("php://input");
+ $postdata = Network::postdata();
if ($postdata == '') {
- System::httpExit(500);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
Logger::log('mod-diaspora: message is in the new format', Logger::DEBUG);
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::log('mod-diaspora: dispatching', Logger::DEBUG);
$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();
+ }
}