mirror of
https://github.com/friendica/friendica
synced 2024-12-23 13:20:21 +00:00
Ensure to transmit the audience if the parent does so
This commit is contained in:
parent
4c3f2441f7
commit
4f6c1ec556
1 changed files with 21 additions and 11 deletions
|
@ -497,7 +497,7 @@ class Transmitter
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
private static function fetchPermissionBlockFromThreadParent(array $item): array
|
private static function fetchPermissionBlockFromThreadParent(array $item, bool $is_group_thread): array
|
||||||
{
|
{
|
||||||
if (empty($item['thr-parent-id'])) {
|
if (empty($item['thr-parent-id'])) {
|
||||||
return [];
|
return [];
|
||||||
|
@ -528,7 +528,9 @@ class Transmitter
|
||||||
$type = [Tag::TO => 'to', Tag::CC => 'cc', Tag::BTO => 'bto', Tag::BCC => 'bcc', Tag::AUDIENCE => 'audience'];
|
$type = [Tag::TO => 'to', Tag::CC => 'cc', Tag::BTO => 'bto', Tag::BCC => 'bcc', Tag::AUDIENCE => 'audience'];
|
||||||
foreach (Tag::getByURIId($item['thr-parent-id'], [Tag::TO, Tag::CC, Tag::BTO, Tag::BCC, Tag::AUDIENCE]) as $receiver) {
|
foreach (Tag::getByURIId($item['thr-parent-id'], [Tag::TO, Tag::CC, Tag::BTO, Tag::BCC, Tag::AUDIENCE]) as $receiver) {
|
||||||
if (!empty($parent_profile['followers']) && $receiver['url'] == $parent_profile['followers'] && !empty($item_profile['followers'])) {
|
if (!empty($parent_profile['followers']) && $receiver['url'] == $parent_profile['followers'] && !empty($item_profile['followers'])) {
|
||||||
|
if (!$is_group_thread) {
|
||||||
$permissions[$type[$receiver['type']]][] = $item_profile['followers'];
|
$permissions[$type[$receiver['type']]][] = $item_profile['followers'];
|
||||||
|
}
|
||||||
} elseif (!in_array($receiver['url'], $exclude)) {
|
} elseif (!in_array($receiver['url'], $exclude)) {
|
||||||
$permissions[$type[$receiver['type']]][] = $receiver['url'];
|
$permissions[$type[$receiver['type']]][] = $receiver['url'];
|
||||||
}
|
}
|
||||||
|
@ -600,6 +602,7 @@ class Transmitter
|
||||||
|
|
||||||
$exclusive = false;
|
$exclusive = false;
|
||||||
$mention = false;
|
$mention = false;
|
||||||
|
$audience = [];
|
||||||
|
|
||||||
$parent_tags = Tag::getByURIId($item['parent-uri-id'], [Tag::AUDIENCE, Tag::MENTION]);
|
$parent_tags = Tag::getByURIId($item['parent-uri-id'], [Tag::AUDIENCE, Tag::MENTION]);
|
||||||
if (!empty($parent_tags)) {
|
if (!empty($parent_tags)) {
|
||||||
|
@ -610,13 +613,14 @@ class Transmitter
|
||||||
}
|
}
|
||||||
$profile = APContact::getByURL($tag['url'], false);
|
$profile = APContact::getByURL($tag['url'], false);
|
||||||
if (!empty($profile) && ($profile['type'] == 'Group')) {
|
if (!empty($profile) && ($profile['type'] == 'Group')) {
|
||||||
|
$audience[] = $tag['url'];
|
||||||
$is_group_thread = true;
|
$is_group_thread = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($is_group_thread) {
|
if ($is_group_thread) {
|
||||||
foreach ($parent_tags as $tag) {
|
foreach ($parent_tags as $tag) {
|
||||||
if (($tag['type'] == Tag::MENTION) && ($tag['url'] == $profile['url'])) {
|
if (($tag['type'] == Tag::MENTION) && in_array($tag['url'], $audience)) {
|
||||||
$mention = false;
|
$mention = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$exclusive = !$mention;
|
$exclusive = !$mention;
|
||||||
|
@ -626,6 +630,7 @@ class Transmitter
|
||||||
$profile = APContact::getByURL($term['url'], false);
|
$profile = APContact::getByURL($term['url'], false);
|
||||||
if (!empty($profile) && ($profile['type'] == 'Group')) {
|
if (!empty($profile) && ($profile['type'] == 'Group')) {
|
||||||
if ($term['type'] == Tag::EXCLUSIVE_MENTION) {
|
if ($term['type'] == Tag::EXCLUSIVE_MENTION) {
|
||||||
|
$audience[] = $term['url'];
|
||||||
$exclusive = true;
|
$exclusive = true;
|
||||||
} elseif ($term['type'] == Tag::MENTION) {
|
} elseif ($term['type'] == Tag::MENTION) {
|
||||||
$mention = true;
|
$mention = true;
|
||||||
|
@ -642,7 +647,7 @@ class Transmitter
|
||||||
$networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
|
$networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = ['to' => [], 'cc' => [], 'bcc' => [] , 'audience' => []];
|
$data = ['to' => [], 'cc' => [], 'bcc' => [] , 'audience' => $audience];
|
||||||
|
|
||||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||||
$actor_profile = APContact::getByURL($item['owner-link']);
|
$actor_profile = APContact::getByURL($item['owner-link']);
|
||||||
|
@ -650,8 +655,7 @@ class Transmitter
|
||||||
$actor_profile = APContact::getByURL($item['author-link']);
|
$actor_profile = APContact::getByURL($item['author-link']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION, Tag::AUDIENCE]);
|
||||||
$terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
|
|
||||||
|
|
||||||
if ($item['private'] != Item::PRIVATE) {
|
if ($item['private'] != Item::PRIVATE) {
|
||||||
// Directly mention the original author upon a quoted reshare.
|
// Directly mention the original author upon a quoted reshare.
|
||||||
|
@ -663,8 +667,8 @@ class Transmitter
|
||||||
$data['cc'][] = $announce['actor']['url'];
|
$data['cc'][] = $announce['actor']['url'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$is_group_thread) {
|
if (!$exclusive) {
|
||||||
$data = array_merge($data, self::fetchPermissionBlockFromThreadParent($item));
|
$data = array_merge($data, self::fetchPermissionBlockFromThreadParent($item, $is_group_thread));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the item is completely public or unlisted
|
// Check if the item is completely public or unlisted
|
||||||
|
@ -677,6 +681,9 @@ class Transmitter
|
||||||
foreach ($terms as $term) {
|
foreach ($terms as $term) {
|
||||||
$profile = APContact::getByURL($term['url'], false);
|
$profile = APContact::getByURL($term['url'], false);
|
||||||
if (!empty($profile)) {
|
if (!empty($profile)) {
|
||||||
|
if (($term['type'] == Tag::AUDIENCE) && ($profile['type'] == 'Group')) {
|
||||||
|
$data['audience'][] = $profile['url'];
|
||||||
|
}
|
||||||
if ($term['type'] == Tag::EXCLUSIVE_MENTION) {
|
if ($term['type'] == Tag::EXCLUSIVE_MENTION) {
|
||||||
$exclusive = true;
|
$exclusive = true;
|
||||||
if (!empty($profile['followers']) && ($profile['type'] == 'Group')) {
|
if (!empty($profile['followers']) && ($profile['type'] == 'Group')) {
|
||||||
|
@ -705,6 +712,9 @@ class Transmitter
|
||||||
|
|
||||||
$profile = APContact::getByURL($term['url'], false);
|
$profile = APContact::getByURL($term['url'], false);
|
||||||
if (!empty($profile)) {
|
if (!empty($profile)) {
|
||||||
|
if (($term['type'] == Tag::AUDIENCE) && ($profile['type'] == 'Group')) {
|
||||||
|
$data['audience'][] = $profile['url'];
|
||||||
|
}
|
||||||
if ($term['type'] == Tag::EXCLUSIVE_MENTION) {
|
if ($term['type'] == Tag::EXCLUSIVE_MENTION) {
|
||||||
$exclusive = true;
|
$exclusive = true;
|
||||||
if (!empty($profile['followers']) && ($profile['type'] == 'Group')) {
|
if (!empty($profile['followers']) && ($profile['type'] == 'Group')) {
|
||||||
|
@ -748,7 +758,7 @@ class Transmitter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($item['parent']) && (!$is_group_thread || ($item['private'] == Item::PRIVATE))) {
|
if (!empty($item['parent']) && (!$exclusive || ($item['private'] == Item::PRIVATE))) {
|
||||||
if ($item['private'] == Item::PRIVATE) {
|
if ($item['private'] == Item::PRIVATE) {
|
||||||
$condition = ['parent' => $item['parent'], 'uri-id' => $item['thr-parent-id']];
|
$condition = ['parent' => $item['parent'], 'uri-id' => $item['thr-parent-id']];
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue