3 * @file src/Module/Inbox.php
5 namespace Friendica\Module;
7 use Friendica\BaseModule;
8 use Friendica\Protocol\ActivityPub;
9 use Friendica\Core\System;
10 use Friendica\Database\DBA;
11 use Friendica\Util\HTTPSignature;
16 class Inbox extends BaseModule
18 public static function rawContent()
22 $postdata = file_get_contents('php://input');
24 if (empty($postdata)) {
25 System::httpExit(400);
28 // Enable for test purposes
30 if (HTTPSignature::getSigner($postdata, $_SERVER)) {
31 $filename = 'signed-activitypub';
33 $filename = 'failed-activitypub';
36 $tempfile = tempnam(get_temppath(), $filename);
37 file_put_contents($tempfile, json_encode(['argv' => $a->argv, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
39 logger('Incoming message stored under ' . $tempfile);
41 if (!empty($a->argv[1])) {
42 $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
43 if (!DBA::isResult($user)) {
44 System::httpExit(404);
51 ActivityPub::processInbox($postdata, $_SERVER, $uid);
53 System::httpExit(202);