3 * @file src/Module/Objects.php
5 namespace Friendica\Module;
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;
17 class Objects extends BaseModule
19 public static function rawContent()
23 if (empty($a->argv[1])) {
24 System::httpExit(404);
27 if (!ActivityPub::isRequest()) {
28 $a->internalRedirect(str_replace('objects/', 'display/', $a->query_string));
31 /// @todo Add Authentication to enable fetching of non public content
32 // $requester = HTTPSignature::getSigner('', $_SERVER);
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);
44 $data = ActivityPub\Transmitter::createObjectFromItemID($item['id']);
46 header('Content-Type: application/activity+json');
47 echo json_encode($data);