Proper Attentions

This commit is contained in:
Diogo Cordeiro 2018-08-01 01:50:27 +01:00
parent 42bfb78184
commit 69b252b244
2 changed files with 6 additions and 25 deletions

View File

@ -78,28 +78,9 @@ $act->context->attention = common_get_attentions($content, $actor_profile, $inRe
$discovery = new Activitypub_explorer;
if ($to_profiles == "https://www.w3.org/ns/activitystreams#Public") {
$to_profiles = array();
}
// Generate To objects
if (is_array($data->object->to)) {
// Remove duplicates from To actors set
array_unique($data->object->to);
foreach ($data->object->to as $to_url) {
try {
$to_profiles = array_merge($to_profiles, $discovery->lookup($to_url));
} catch (Exception $e) {
// Invalid actor found, just let it go.
}
}
} elseif (empty($data->object->to) || in_array($data->object->to, $public_to)) {
// No need to do anything else at this point, let's just break out the if
} else {
try {
$to_profiles = array_merge($to_profiles, $discovery->lookup($data->object->to));
} catch (Exception $e) {
// Invalid actor found, just let it go.
}
$to_profiles = [];
}
// Generate Cc objects
if (isset($data->object->cc) && is_array($data->object->cc)) {
// Remove duplicates from Cc actors set

View File

@ -62,9 +62,9 @@ class Activitypub_notice extends Managed_DataObject
}
}
$to = [];
$cc = [common_local_url('apActorFollowers', ['id' => $profile->getID()])];
foreach ($notice->getAttentionProfiles() as $to_profile) {
$to[] = $href = $to_profile->getUri();
$cc[] = $href = $to_profile->getUri();
$tags[] = Activitypub_mention_tag::mention_tag_to_array_from_values($href, $to_profile->getNickname().'@'.parse_url($href, PHP_URL_HOST));
}
@ -78,8 +78,8 @@ class Activitypub_notice extends Managed_DataObject
'published' => str_replace(' ', 'T', $notice->getCreated()).'Z',
'url' => $notice->getUrl(),
'atributtedTo' => ActivityPubPlugin::actor_uri($profile),
'to' => $to,
'cc' => common_local_url('apActorFollowers', ['id' => $profile->getID()]),
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'cc' => $cc,
'atomUri' => $notice->getUrl(),
'conversation' => $notice->getConversationUrl(),
'content' => $notice->getRendered(),