forked from GNUsocial/gnu-social
[PLUGIN][ActivityPub][Model][Note] Handle group scope properly
This commit is contained in:
parent
27635d8ec2
commit
99f7e7cd79
@ -171,7 +171,7 @@ class Note extends Model
|
|||||||
} elseif (\in_array('https://www.w3.org/ns/activitystreams#Public', $cc)) {
|
} elseif (\in_array('https://www.w3.org/ns/activitystreams#Public', $cc)) {
|
||||||
// Unlisted: Visible for all but not shown in public feeds
|
// Unlisted: Visible for all but not shown in public feeds
|
||||||
// It isn't the note that dictates what feed is shown in but the feed, it only dictates who can access it.
|
// It isn't the note that dictates what feed is shown in but the feed, it only dictates who can access it.
|
||||||
$map['scope'] = VisibilityScope::EVERYWHERE;
|
$map['scope'] = 'unlisted';
|
||||||
} else {
|
} else {
|
||||||
// Either Followers-only or Direct
|
// Either Followers-only or Direct
|
||||||
if ($type_note->get('directMessage') ?? false // Is DM explicitly?
|
if ($type_note->get('directMessage') ?? false // Is DM explicitly?
|
||||||
@ -190,14 +190,20 @@ class Note extends Model
|
|||||||
try {
|
try {
|
||||||
$actor = ActivityPub::getActorByUri($target);
|
$actor = ActivityPub::getActorByUri($target);
|
||||||
$object_mentions_ids[$actor->getId()] = $target;
|
$object_mentions_ids[$actor->getId()] = $target;
|
||||||
// If $to is a group, set note's scope as Group
|
// If $to is a group and note is unlisted, set note's scope as Group
|
||||||
if ($actor->isGroup()) {
|
if ($actor->isGroup() && $map['scope'] === 'unlisted') {
|
||||||
$map['scope'] = VisibilityScope::GROUP;
|
$map['scope'] = VisibilityScope::GROUP;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::debug('ActivityPub->Model->Note->fromJson->getActorByUri', [$e]);
|
Log::debug('ActivityPub->Model->Note->fromJson->getActorByUri', [$e]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We can drop this insight already
|
||||||
|
if ($map['scope'] === 'unlisted') {
|
||||||
|
$map['scope'] = VisibilityScope::EVERYWHERE;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($cc as $target) {
|
foreach ($cc as $target) {
|
||||||
if ($target === 'https://www.w3.org/ns/activitystreams#Public') {
|
if ($target === 'https://www.w3.org/ns/activitystreams#Public') {
|
||||||
continue;
|
continue;
|
||||||
@ -362,7 +368,8 @@ class Note extends Model
|
|||||||
$attr['cc'] = [];
|
$attr['cc'] = [];
|
||||||
break;
|
break;
|
||||||
case VisibilityScope::GROUP:
|
case VisibilityScope::GROUP:
|
||||||
// Will have the group in the To
|
// Will have the group in the To coming from attentions
|
||||||
|
// no break
|
||||||
case VisibilityScope::COLLECTION:
|
case VisibilityScope::COLLECTION:
|
||||||
// Since we don't support sending unlisted/followers-only
|
// Since we don't support sending unlisted/followers-only
|
||||||
// notices, arriving here means we're instead answering to that type
|
// notices, arriving here means we're instead answering to that type
|
||||||
@ -377,7 +384,12 @@ class Note extends Model
|
|||||||
|
|
||||||
$attention_cc = DB::findBy(Attention::class, ['note_id' => $object->getId()]);
|
$attention_cc = DB::findBy(Attention::class, ['note_id' => $object->getId()]);
|
||||||
foreach($attention_cc as $cc_id) {
|
foreach($attention_cc as $cc_id) {
|
||||||
$attr['cc'][] = \App\Entity\Actor::getById($cc_id->getTargetId())->getUri(Router::ABSOLUTE_URL);
|
$target = \App\Entity\Actor::getById($cc_id->getTargetId());
|
||||||
|
if ($object->getScope() === VisibilityScope::GROUP && $target->isGroup()) {
|
||||||
|
$attr['to'][] = $target->getUri(Router::ABSOLUTE_URL);
|
||||||
|
} else {
|
||||||
|
$attr['cc'][] = $target->getUri(Router::ABSOLUTE_URL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mentions
|
// Mentions
|
||||||
|
Loading…
Reference in New Issue
Block a user