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;
14 use Friendica\Protocol\ActivityPub;
15 use Friendica\Util\HTTPSignature;
16 use Friendica\Util\Network;
21 class Inbox extends BaseModule
23 public static function rawContent(array $parameters = [])
27 $postdata = Network::postdata();
29 if (empty($postdata)) {
30 throw new \Friendica\Network\HTTPException\BadRequestException();
33 if (DI::config()->get('debug', 'ap_inbox_log')) {
34 if (HTTPSignature::getSigner($postdata, $_SERVER)) {
35 $filename = 'signed-activitypub';
37 $filename = 'failed-activitypub';
39 $tempfile = tempnam(get_temppath(), $filename);
40 file_put_contents($tempfile, json_encode(['argv' => $a->argv, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
41 Logger::log('Incoming message stored under ' . $tempfile);
44 // @TODO: Replace with parameter from router
45 if (!empty($a->argv[1])) {
46 $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
47 if (!DBA::isResult($user)) {
48 throw new \Friendica\Network\HTTPException\NotFoundException();
55 ActivityPub\Receiver::processInbox($postdata, $_SERVER, $uid);
57 throw new \Friendica\Network\HTTPException\AcceptedException();