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;
12 use Friendica\Core\Logger;
17 class Inbox extends BaseModule
19 public static function rawContent()
23 $postdata = file_get_contents('php://input');
25 if (empty($postdata)) {
26 System::httpExit(400);
29 // Enable for test purposes
31 if (HTTPSignature::getSigner($postdata, $_SERVER)) {
32 $filename = 'signed-activitypub';
34 $filename = 'failed-activitypub';
37 $tempfile = tempnam(get_temppath(), $filename);
38 file_put_contents($tempfile, json_encode(['argv' => $a->argv, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
40 Logger::log('Incoming message stored under ' . $tempfile);
42 if (!empty($a->argv[1])) {
43 $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
44 if (!DBA::isResult($user)) {
45 System::httpExit(404);
52 ActivityPub\Receiver::processInbox($postdata, $_SERVER, $uid);
54 System::httpExit(202);