]> git.mxchange.org Git - friendica.git/blob - src/Module/Inbox.php
Move Photo module, update Photo model
[friendica.git] / src / Module / Inbox.php
1 <?php
2 /**
3  * @file src/Module/Inbox.php
4  */
5 namespace Friendica\Module;
6
7 use Friendica\BaseModule;
8 use Friendica\Protocol\ActivityPub;
9 use Friendica\Core\System;
10 use Friendica\Database\DBA;
11 use Friendica\Util\HTTPSignature;
12 use Friendica\Core\Logger;
13
14 /**
15  * ActivityPub Inbox
16  */
17 class Inbox extends BaseModule
18 {
19         public static function rawContent()
20         {
21                 $a = self::getApp();
22
23                 $postdata = file_get_contents('php://input');
24
25                 if (empty($postdata)) {
26                         System::httpExit(400);
27                 }
28
29 // Enable for test purposes
30 /*
31                 if (HTTPSignature::getSigner($postdata, $_SERVER)) {
32                         $filename = 'signed-activitypub';
33                 } else {
34                         $filename = 'failed-activitypub';
35                 }
36
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
40                 Logger::log('Incoming message stored under ' . $tempfile);
41 */
42                 if (!empty($a->argv[1])) {
43                         $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
44                         if (!DBA::isResult($user)) {
45                                 System::httpExit(404);
46                         }
47                         $uid = $user['uid'];
48                 } else {
49                         $uid = 0;
50                 }
51
52                 ActivityPub\Receiver::processInbox($postdata, $_SERVER, $uid);
53
54                 System::httpExit(202);
55         }
56 }