mirror of
https://github.com/friendica/friendica
synced 2025-04-23 00:30:11 +00:00
Merge pull request #11251 from annando/forum2
Fix for private communities
This commit is contained in:
commit
6c0dbc1775
2 changed files with 30 additions and 31 deletions
|
@ -70,9 +70,7 @@ class Objects extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
$item = Post::selectFirst(['id', 'uid', 'origin', 'author-link', 'changed', 'private', 'psid', 'gravity', 'deleted', 'parent-uri-id'],
|
||||
['uri-id' => $itemuri['id']], ['order' => ['origin' => true]]);
|
||||
|
||||
$item = Post::selectFirst([], ['uri-id' => $itemuri['id'], 'origin' => true]);
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
@ -81,25 +79,16 @@ class Objects extends BaseModule
|
|||
|
||||
if (!$validated) {
|
||||
$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']);
|
||||
$psids = array_merge($permissionSets->column('id'), [PermissionSet::PUBLIC]);
|
||||
$validated = in_array($item['psid'], $psids);
|
||||
if (!empty($requester)) {
|
||||
$receivers = Item::enumeratePermissions($item, false);
|
||||
|
||||
$validated = in_array(Contact::getIdForURL($requester, $item['uid']), $receivers);
|
||||
if (!$validated) {
|
||||
$validated = in_array(Contact::getIdForURL($requester), $receivers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($validated) {
|
||||
// Valid items are original post or posted from this node (including in the case of a forum)
|
||||
$validated = ($item['origin'] || (parse_url($item['author-link'], PHP_URL_HOST) == parse_url(DI::baseUrl()->get(), PHP_URL_HOST)));
|
||||
|
||||
if (!$validated && $item['deleted']) {
|
||||
$validated = Post::exists(['origin' => true, 'uri-id' => $item['parent-uri-id']]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$validated) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue