kopia lustrzana https://github.com/friendica/friendica
Merge pull request #11429 from annando/issue-11427
Issue 11427: id values of OrderedCollections have to contain the page numberpull/11430/head
commit
691136c396
|
@ -42,7 +42,7 @@ class Featured extends BaseModule
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = $request['page'] ?? null;
|
$page = !empty($request['page']) ? (int)$request['page'] : null;
|
||||||
|
|
||||||
$featured = ActivityPub\Transmitter::getFeatured($owner, $page);
|
$featured = ActivityPub\Transmitter::getFeatured($owner, $page);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Followers extends BaseModule
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = $_REQUEST['page'] ?? null;
|
$page = !empty($request['page']) ? (int)$request['page'] : null;
|
||||||
|
|
||||||
$followers = ActivityPub\Transmitter::getContacts($owner, [Contact::FOLLOWER, Contact::FRIEND], 'followers', $page, (string)HTTPSignature::getSigner('', $_SERVER));
|
$followers = ActivityPub\Transmitter::getContacts($owner, [Contact::FOLLOWER, Contact::FRIEND], 'followers', $page, (string)HTTPSignature::getSigner('', $_SERVER));
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Following extends BaseModule
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = $_REQUEST['page'] ?? null;
|
$page = !empty($request['page']) ? (int)$request['page'] : null;
|
||||||
|
|
||||||
$following = ActivityPub\Transmitter::getContacts($owner, [Contact::SHARING, Contact::FRIEND], 'following', $page);
|
$following = ActivityPub\Transmitter::getContacts($owner, [Contact::SHARING, Contact::FRIEND], 'following', $page);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Outbox extends BaseModule
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = $_REQUEST['page'] ?? null;
|
$page = !empty($request['page']) ? (int)$request['page'] : null;
|
||||||
|
|
||||||
$requester = HTTPSignature::getSigner('', $_SERVER);
|
$requester = HTTPSignature::getSigner('', $_SERVER);
|
||||||
$outbox = ActivityPub\Transmitter::getOutbox($owner, $page, $requester);
|
$outbox = ActivityPub\Transmitter::getOutbox($owner, $page, $requester);
|
||||||
|
|
|
@ -146,16 +146,16 @@ class Transmitter
|
||||||
/**
|
/**
|
||||||
* Collects a list of contacts of the given owner
|
* Collects a list of contacts of the given owner
|
||||||
*
|
*
|
||||||
* @param array $owner Owner array
|
* @param array $owner Owner array
|
||||||
* @param int|array $rel The relevant value(s) contact.rel should match
|
* @param array $rel The relevant value(s) contact.rel should match
|
||||||
* @param string $module The name of the relevant AP endpoint module (followers|following)
|
* @param string $module The name of the relevant AP endpoint module (followers|following)
|
||||||
* @param integer $page Page number
|
* @param integer $page Page number
|
||||||
* @param string $requester URL of the requester
|
* @param string $requester URL of the requester
|
||||||
*
|
*
|
||||||
* @return array of owners
|
* @return array of owners
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function getContacts($owner, $rel, $module, $page = null, string $requester = null)
|
public static function getContacts(array $owner, array $rel, string $module, int $page = null, string $requester = null)
|
||||||
{
|
{
|
||||||
$parameters = [
|
$parameters = [
|
||||||
'rel' => $rel,
|
'rel' => $rel,
|
||||||
|
@ -179,6 +179,10 @@ class Transmitter
|
||||||
$data['type'] = 'OrderedCollection';
|
$data['type'] = 'OrderedCollection';
|
||||||
$data['totalItems'] = $total;
|
$data['totalItems'] = $total;
|
||||||
|
|
||||||
|
if (!empty($page)) {
|
||||||
|
$data['id'] .= '?' . http_build_query(['page' => $page]);
|
||||||
|
}
|
||||||
|
|
||||||
// When we hide our friends we will only show the pure number but don't allow more.
|
// When we hide our friends we will only show the pure number but don't allow more.
|
||||||
$show_contacts = empty($owner['hide-friends']);
|
$show_contacts = empty($owner['hide-friends']);
|
||||||
|
|
||||||
|
@ -203,7 +207,7 @@ class Transmitter
|
||||||
}
|
}
|
||||||
DBA::close($contacts);
|
DBA::close($contacts);
|
||||||
|
|
||||||
if (!empty($list)) {
|
if (count($list) == 100) {
|
||||||
$data['next'] = DI::baseUrl() . $modulePath . $owner['nickname'] . '?page=' . ($page + 1);
|
$data['next'] = DI::baseUrl() . $modulePath . $owner['nickname'] . '?page=' . ($page + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +230,7 @@ class Transmitter
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
public static function getOutbox($owner, $page = null, $requester = '')
|
public static function getOutbox(array $owner, int $page = null, string $requester = '')
|
||||||
{
|
{
|
||||||
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED]];
|
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED]];
|
||||||
|
|
||||||
|
@ -258,6 +262,10 @@ class Transmitter
|
||||||
$data['type'] = 'OrderedCollection';
|
$data['type'] = 'OrderedCollection';
|
||||||
$data['totalItems'] = $count;
|
$data['totalItems'] = $count;
|
||||||
|
|
||||||
|
if (!empty($page)) {
|
||||||
|
$data['id'] .= '?' . http_build_query(['page' => $page]);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($page)) {
|
if (empty($page)) {
|
||||||
$data['first'] = DI::baseUrl() . '/outbox/' . $owner['nickname'] . '?page=1';
|
$data['first'] = DI::baseUrl() . '/outbox/' . $owner['nickname'] . '?page=1';
|
||||||
} else {
|
} else {
|
||||||
|
@ -276,7 +284,7 @@ class Transmitter
|
||||||
}
|
}
|
||||||
DBA::close($items);
|
DBA::close($items);
|
||||||
|
|
||||||
if (!empty($list)) {
|
if (count($list) == 20) {
|
||||||
$data['next'] = DI::baseUrl() . '/outbox/' . $owner['nickname'] . '?page=' . ($page + 1);
|
$data['next'] = DI::baseUrl() . '/outbox/' . $owner['nickname'] . '?page=' . ($page + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +306,7 @@ class Transmitter
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
public static function getFeatured($owner, $page = null)
|
public static function getFeatured(array $owner, int $page = null)
|
||||||
{
|
{
|
||||||
$condition = ["`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
|
$condition = ["`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
|
||||||
Contact::getIdForURL($owner['url'], 0, false), Post\Collection::FEATURED];
|
Contact::getIdForURL($owner['url'], 0, false), Post\Collection::FEATURED];
|
||||||
|
@ -321,6 +329,10 @@ class Transmitter
|
||||||
$data['type'] = 'OrderedCollection';
|
$data['type'] = 'OrderedCollection';
|
||||||
$data['totalItems'] = $count;
|
$data['totalItems'] = $count;
|
||||||
|
|
||||||
|
if (!empty($page)) {
|
||||||
|
$data['id'] .= '?' . http_build_query(['page' => $page]);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($page)) {
|
if (empty($page)) {
|
||||||
$data['first'] = DI::baseUrl() . '/featured/' . $owner['nickname'] . '?page=1';
|
$data['first'] = DI::baseUrl() . '/featured/' . $owner['nickname'] . '?page=1';
|
||||||
} else {
|
} else {
|
||||||
|
@ -339,7 +351,7 @@ class Transmitter
|
||||||
}
|
}
|
||||||
DBA::close($items);
|
DBA::close($items);
|
||||||
|
|
||||||
if (!empty($list)) {
|
if (count($list) == 20) {
|
||||||
$data['next'] = DI::baseUrl() . '/featured/' . $owner['nickname'] . '?page=' . ($page + 1);
|
$data['next'] = DI::baseUrl() . '/featured/' . $owner['nickname'] . '?page=' . ($page + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue