]> git.mxchange.org Git - friendica.git/blob - src/Module/Objects.php
Revert logic change in query in NotificationsManager->setSeen
[friendica.git] / src / Module / Objects.php
1 <?php
2 /**
3  * @file src/Module/Objects.php
4  */
5 namespace Friendica\Module;
6
7 use Friendica\BaseModule;
8 use Friendica\Protocol\ActivityPub;
9 use Friendica\Core\System;
10 use Friendica\Model\Item;
11 use Friendica\Database\DBA;
12 use Friendica\Util\HTTPSignature;
13
14 /**
15  * ActivityPub Objects
16  */
17 class Objects extends BaseModule
18 {
19         public static function rawContent()
20         {
21                 $a = self::getApp();
22
23                 if (empty($a->argv[1])) {
24                         System::httpExit(404);
25                 }
26
27                 if (!ActivityPub::isRequest()) {
28                         $a->internalRedirect(str_replace('objects/', 'display/', $a->query_string));
29                 }
30
31                 /// @todo Add Authentication to enable fetching of non public content
32                 // $requester = HTTPSignature::getSigner('', $_SERVER);
33
34                 // At first we try the original post with that guid
35                 $item = Item::selectFirst(['id'], ['guid' => $a->argv[1], 'origin' => true, 'private' => false]);
36                 if (!DBA::isResult($item)) {
37                         // If no original post could be found, it could possibly be a forum post, there we remove the "origin" field.
38                         $item = Item::selectFirst(['id', 'author-link'], ['guid' => $a->argv[1], 'private' => false]);
39                         if (!DBA::isResult($item) || !strstr($item['author-link'], System::baseUrl())) {
40                                 System::httpExit(404);
41                         }
42                 }
43
44                 $data = ActivityPub\Transmitter::createObjectFromItemID($item['id']);
45
46                 header('Content-Type: application/activity+json');
47                 echo json_encode($data);
48                 exit();
49         }
50 }