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 init()
22 $postdata = file_get_contents('php://input');
24 if (empty($postdata)) {
25 System::httpExit(400);
28 if (HTTPSignature::getSigner($postdata, $_SERVER)) {
29 $filename = 'signed-activitypub';
31 $filename = 'failed-activitypub';
34 $tempfile = tempnam(get_temppath(), $filename);
35 file_put_contents($tempfile, json_encode(['argv' => $a->argv, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
37 logger('Incoming message stored under ' . $tempfile);
39 if (!empty($a->argv[1])) {
40 $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
41 if (!DBA::isResult($user)) {
42 System::httpExit(404);
49 ActivityPub::processInbox($postdata, $_SERVER, $uid);
51 System::httpExit(202);