Support fetching private posts
This commit is contained in:
parent
bdd834d313
commit
729d5ebaf1
|
@ -25,9 +25,11 @@ use Friendica\BaseModule;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
|
use Friendica\Util\HTTPSignature;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,17 +47,27 @@ class Objects extends BaseModule
|
||||||
DI::baseUrl()->redirect(str_replace('objects/', 'display/', DI::args()->getQueryString()));
|
DI::baseUrl()->redirect(str_replace('objects/', 'display/', DI::args()->getQueryString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @todo Add Authentication to enable fetching of non public content
|
$item = Item::selectFirst(['id', 'uid', 'origin', 'author-link', 'changed', 'private', 'psid'],
|
||||||
// $requester = HTTPSignature::getSigner('', $_SERVER);
|
['guid' => $parameters['guid']], ['order' => ['origin' => true]]);
|
||||||
|
|
||||||
|
$validated = false;
|
||||||
|
$requester = HTTPSignature::getSigner('', $_SERVER);
|
||||||
|
if (!empty($requester) && $item['origin']) {
|
||||||
|
$requester_id = Contact::getIdForURL($requester, $item['uid']);
|
||||||
|
if (!empty($requester_id)) {
|
||||||
|
$permissionSets = DI::permissionSet()->selectByContactId($requester_id, $item['uid']);
|
||||||
|
if (!empty($permissionSets)) {
|
||||||
|
$psid = array_merge($permissionSets->column('id'),
|
||||||
|
[DI::permissionSet()->getIdFromACL($item['uid'], '', '', '', '')]);
|
||||||
|
$validated = in_array($item['psid'], $psid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$validated && !in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) {
|
||||||
|
unset($item);
|
||||||
|
}
|
||||||
|
|
||||||
$item = Item::selectFirst(
|
|
||||||
['id', 'origin', 'author-link', 'changed'],
|
|
||||||
[
|
|
||||||
'guid' => $parameters['guid'],
|
|
||||||
'private' => [Item::PUBLIC, Item::UNLISTED]
|
|
||||||
],
|
|
||||||
['order' => ['origin' => true]]
|
|
||||||
);
|
|
||||||
// Valid items are original post or posted from this node (including in the case of a forum)
|
// Valid items are original post or posted from this node (including in the case of a forum)
|
||||||
if (!DBA::isResult($item) || !$item['origin'] && (parse_url($item['author-link'], PHP_URL_HOST) != parse_url(DI::baseUrl()->get(), PHP_URL_HOST))) {
|
if (!DBA::isResult($item) || !$item['origin'] && (parse_url($item['author-link'], PHP_URL_HOST) != parse_url(DI::baseUrl()->get(), PHP_URL_HOST))) {
|
||||||
throw new HTTPException\NotFoundException();
|
throw new HTTPException\NotFoundException();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user