"audience" is set for forum posts / followers posts are directed to the followers collection

This commit is contained in:
Michael 2023-04-28 05:13:23 +00:00
parent 9e13ef4021
commit ae6c354232
3 changed files with 75 additions and 38 deletions

View file

@ -392,21 +392,23 @@ class Group
/**
* Returns the combined list of contact ids from a group id list
*
* @param int $uid User id
* @param array $group_ids Groups ids
* @param boolean $check_dead Whether check "dead" records (?)
* @param int $uid User id
* @param array $group_ids Groups ids
* @param boolean $check_dead Whether check "dead" records (?)
* @param boolean $expand_followers Expand the list of followers
* @return array
* @throws \Exception
*/
public static function expand(int $uid, array $group_ids, bool $check_dead = false): array
public static function expand(int $uid, array $group_ids, bool $check_dead = false, bool $expand_followers = true): array
{
if (!is_array($group_ids) || !count($group_ids)) {
return [];
}
$return = [];
$pubmail = false;
$networks = Protocol::SUPPORT_PRIVATE;
$return = [];
$pubmail = false;
$followers_collection = false;
$networks = Protocol::SUPPORT_PRIVATE;
$mailacct = DBA::selectFirst('mailacct', ['pubmail'], ['`uid` = ? AND `server` != ""', $uid]);
if (DBA::isResult($mailacct)) {
@ -419,20 +421,23 @@ class Group
$key = array_search(self::FOLLOWERS, $group_ids);
if ($key !== false) {
$followers = Contact::selectToArray(['id'], [
'uid' => $uid,
'rel' => [Contact::FOLLOWER, Contact::FRIEND],
'network' => $networks,
'contact-type' => [Contact::TYPE_UNKNOWN, Contact::TYPE_PERSON],
'archive' => false,
'pending' => false,
'blocked' => false,
]);
if ($expand_followers) {
$followers = Contact::selectToArray(['id'], [
'uid' => $uid,
'rel' => [Contact::FOLLOWER, Contact::FRIEND],
'network' => $networks,
'contact-type' => [Contact::TYPE_UNKNOWN, Contact::TYPE_PERSON],
'archive' => false,
'pending' => false,
'blocked' => false,
]);
foreach ($followers as $follower) {
$return[] = $follower['id'];
foreach ($followers as $follower) {
$return[] = $follower['id'];
}
} else {
$followers_collection = true;
}
unset($group_ids[$key]);
}
@ -465,6 +470,10 @@ class Group
$return = Contact::pruneUnavailable($return);
}
if ($followers_collection) {
$return[] = -1;
}
return $return;
}

View file

@ -2510,17 +2510,22 @@ class Item
/**
* Returns an array of contact-ids that are allowed to see this object
*
* @param array $obj Item array with at least uid, allow_cid, allow_gid, deny_cid and deny_gid
* @param bool $check_dead Prunes unavailable contacts from the result
* @param array $obj Item array with at least uid, allow_cid, allow_gid, deny_cid and deny_gid
* @param bool $check_dead Prunes unavailable contacts from the result
* @param bool $expand_followers Expand the list of followers
* @return array
* @throws \Exception
*/
public static function enumeratePermissions(array $obj, bool $check_dead = false): array
public static function enumeratePermissions(array $obj, bool $check_dead = false, bool $expand_followers = true): array
{
$aclFormatter = DI::aclFormatter();
if (!$expand_followers && (!empty($obj['deny_cid']) || !empty($obj['deny_gid']))) {
$expand_followers = true;
}
$allow_people = $aclFormatter->expand($obj['allow_cid']);
$allow_groups = Group::expand($obj['uid'], $aclFormatter->expand($obj['allow_gid']), $check_dead);
$allow_groups = Group::expand($obj['uid'], $aclFormatter->expand($obj['allow_gid']), $check_dead, $expand_followers);
$deny_people = $aclFormatter->expand($obj['deny_cid']);
$deny_groups = Group::expand($obj['uid'], $aclFormatter->expand($obj['deny_gid']), $check_dead);
$recipients = array_unique(array_merge($allow_people, $allow_groups));