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;
15 use Friendica\Util\Network;
20 class Inbox extends BaseModule
22 public static function rawContent(array $parameters = [])
26 $postdata = Network::postdata();
28 if (empty($postdata)) {
29 throw new \Friendica\Network\HTTPException\BadRequestException();
32 if (Config::get('debug', 'ap_inbox_log')) {
33 if (HTTPSignature::getSigner($postdata, $_SERVER)) {
34 $filename = 'signed-activitypub';
36 $filename = 'failed-activitypub';
38 $tempfile = tempnam(get_temppath(), $filename);
39 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);
43 // @TODO: Replace with parameter from router
44 if (!empty($a->argv[1])) {
45 $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
46 if (!DBA::isResult($user)) {
47 throw new \Friendica\Network\HTTPException\NotFoundException();
54 ActivityPub\Receiver::processInbox($postdata, $_SERVER, $uid);
56 throw new \Friendica\Network\HTTPException\AcceptedException();