3 * @file src/Module/Inbox.php
6 namespace Friendica\Module;
8 use Friendica\BaseModule;
9 use Friendica\Core\Logger;
10 use Friendica\Database\DBA;
12 use Friendica\Protocol\ActivityPub;
13 use Friendica\Util\HTTPSignature;
14 use Friendica\Util\Network;
19 class Inbox extends BaseModule
21 public static function rawContent(array $parameters = [])
25 $postdata = Network::postdata();
27 if (empty($postdata)) {
28 throw new \Friendica\Network\HTTPException\BadRequestException();
31 if (DI::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 throw new \Friendica\Network\HTTPException\NotFoundException();
53 ActivityPub\Receiver::processInbox($postdata, $_SERVER, $uid);
55 throw new \Friendica\Network\HTTPException\AcceptedException();