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;
15 class Inbox extends BaseModule
17 public static function init()
21 $postdata = file_get_contents('php://input');
23 if (empty($postdata)) {
24 System::httpExit(400);
27 if (ActivityPub::verifySignature($postdata, $_SERVER)) {
28 $filename = 'signed-activitypub';
30 $filename = 'failed-activitypub';
33 $tempfile = tempnam(get_temppath(), $filename);
34 file_put_contents($tempfile, json_encode(['argv' => $a->argv, 'header' => $_SERVER, 'body' => $postdata]));
36 logger('Incoming message stored under ' . $tempfile);
38 if (!empty($a->argv[1])) {
39 $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
40 if (!DBA::isResult($user)) {
41 System::httpExit(404);
48 ActivityPub::processInbox($postdata, $_SERVER, $uid);
50 System::httpExit(201);