use Friendica\Model\Contact;
use Friendica\Model\User;
use Friendica\Protocol\ActivityPub;
+use Friendica\Util\HTTPSignature;
/**
* ActivityPub Followers
$page = $_REQUEST['page'] ?? null;
- $followers = ActivityPub\Transmitter::getContacts($owner, [Contact::FOLLOWER, Contact::FRIEND], 'followers', $page);
+ $followers = ActivityPub\Transmitter::getContacts($owner, [Contact::FOLLOWER, Contact::FRIEND], 'followers', $page, (string)HTTPSignature::getSigner('', $_SERVER));
header('Content-Type: application/activity+json');
echo json_encode($followers);
use Friendica\Model\Item;
use Friendica\Model\Photo;
use Friendica\Model\Post;
-use Friendica\Model\Profile;
use Friendica\Model\Tag;
use Friendica\Model\User;
use Friendica\Network\HTTPException;
use Friendica\Util\LDSignature;
use Friendica\Util\Map;
use Friendica\Util\Network;
+use Friendica\Util\Strings;
use Friendica\Util\XML;
/**
/**
* Collects a list of contacts of the given owner
*
- * @param array $owner Owner array
- * @param int|array $rel The relevant value(s) contact.rel should match
- * @param string $module The name of the relevant AP endpoint module (followers|following)
- * @param integer $page Page number
+ * @param array $owner Owner array
+ * @param int|array $rel The relevant value(s) contact.rel should match
+ * @param string $module The name of the relevant AP endpoint module (followers|following)
+ * @param integer $page Page number
+ * @param string $requester URL of the requester
*
* @return array of owners
* @throws \Exception
*/
- public static function getContacts($owner, $rel, $module, $page = null)
+ public static function getContacts($owner, $rel, $module, $page = null, string $requester = null)
{
$parameters = [
'rel' => $rel,
$data['totalItems'] = $total;
// When we hide our friends we will only show the pure number but don't allow more.
- $profile = Profile::getByUID($owner['uid']);
- if (!empty($profile['hide-friends'])) {
+ $show_contacts = empty($owner['hide-friends']);
+
+ // Allow fetching the contact list when the requester is part of the list.
+ if (($owner['page-flags'] == User::PAGE_FLAGS_PRVGROUP) && !empty($requester)) {
+ $show_contacts = DBA::exists('contact', ['nurl' => Strings::normaliseLink($requester), 'rel' => $rel]);
+ }
+
+ if (!$show_contacts) {
return $data;
}