]> git.mxchange.org Git - friendica.git/blobdiff - mod/receive.php
Issue 7285: Perform duplicate check for item URI also with AP
[friendica.git] / mod / receive.php
index b0258acbd71803b0ac4286cafd31eb5c465d065b..182a1df8c51c345a933be30c517aec30904f3563 100644 (file)
@@ -10,6 +10,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Protocol\Diaspora;
+use Friendica\Util\Network;
 
 /**
  * @param App $a App
@@ -22,7 +23,7 @@ function receive_post(App $a)
        $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')) {
@@ -32,13 +33,13 @@ 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();
                }
        }
 
@@ -47,9 +48,9 @@ function receive_post(App $a)
        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);
@@ -71,7 +72,7 @@ function receive_post(App $a)
        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);
@@ -83,6 +84,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();
+       }
 }