3 * @file src/Module/Inbox.php
6 namespace Friendica\Module;
8 use Friendica\BaseModule;
9 use Friendica\Core\Config;
10 use Friendica\Core\Logger;
11 use Friendica\Core\System;
12 use Friendica\Database\DBA;
13 use Friendica\Protocol\ActivityPub;
14 use Friendica\Util\HTTPSignature;
19 class Inbox extends BaseModule
21 public static function rawContent()
25 $postdata = file_get_contents('php://input');
27 if (empty($postdata)) {
28 System::httpExit(400);
31 if (Config::get('debug', 'ap_inbox_log')) {
32 if (HTTPSignature::getSigner($postdata, $_SERVER)) {
33 $filename = 'signed-activitypub';
35 $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));
39 Logger::log('Incoming message stored under ' . $tempfile);
42 // @TODO: Replace with parameter from router
43 if (!empty($a->argv[1])) {
44 $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
45 if (!DBA::isResult($user)) {
46 System::httpExit(404);
53 ActivityPub\Receiver::processInbox($postdata, $_SERVER, $uid);
55 System::httpExit(202);