Merge branch 'rendered_notices' into 'dev'

some new federation related stuff

See merge request dansup/ActivityPub!17
This commit is contained in:
Diogo Cordeiro 2018-08-01 01:09:48 +00:00
commit 30affa954f
6 changed files with 18 additions and 35 deletions

View File

@ -99,10 +99,12 @@ class ActivityPubPlugin extends Plugin
if ($candidate->getUrl() == $url) { // Sanity check
return $candidate;
} else {
throw new Exception("Notice not found.");
common_debug ('ActivityPubPlugin Notice Grabber: '.$candidate->getUrl(). ' is different of '.$url);
throw new Exception('Notice not found.');
}
} catch (Exception $e) {
throw new Exception("Notice not found.");
common_debug ('ActivityPubPlugin Notice Grabber failed to find: '.$url);
throw new Exception('Notice not found.');
}
}
}

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
@ -144,7 +125,7 @@ ToSelector::fillActivity($this, $act, $options);
$actobj = new ActivityObject();
$actobj->type = ActivityObject::NOTE;
$actobj->content = common_render_content($content, $actor_profile, $inReplyTo);
$actobj->content = strip_tags($content,'<p><b><i><u><a><ul><ol><li>');
// Finally add the activity object to our activity
$act->objects[] = $actobj;

View File

@ -36,7 +36,7 @@ try {
ActivityPubReturn::error("Invalid Object specified.");
}
Fave::addNew($actor_profile, $object_notice);
ActivityPubReturn::answer(Activitypub_like::like_to_array($data->actor, $object_notice));
ActivityPubReturn::answer(Activitypub_like::like_to_array($data->actor, $data->object));
} catch (Exception $e) {
ActivityPubReturn::error($e->getMessage(), 403);
}

View File

@ -76,11 +76,11 @@ case "Follow":
Activitypub_accept::accept_to_array(
Activitypub_follow::follow_to_array(
$actor_profile->getUrl(),
$object_profile->getUrl()
$object_profile->getUrl()
)
)
)
);
)
);
} else {
ActivityPubReturn::error("You are not following this person already.", 409);
}

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,11 +78,11 @@ 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->getContent(),
'content' => $notice->getRendered(),
'isLocal' => $notice->isLocal(),
'attachment' => $attachments,
'tag' => $tags

View File

@ -101,7 +101,7 @@ class Activitypub_explorer
$this->temp_res = $res;
return true;
} else {
common_debug('ActivityPub Explorer: Invalid potential remote actor while ensuring URI: '.$url. '. He returned the following: '.json_encode($res, JSON_PRETTY_PRINT));
common_debug('ActivityPub Explorer: Invalid potential remote actor while ensuring URI: '.$url. '. He returned the following: '.json_encode($res, JSON_UNESCAPED_SLASHES));
}
return false;
@ -208,7 +208,7 @@ class Activitypub_explorer
$this->discovered_actor_profiles[]= $this->store_profile($res);
return true;
} else {
common_debug('ActivityPub Explorer: Invalid potential remote actor while grabbing remotely: '.$url. '. He returned the following: '.json_encode($res, JSON_PRETTY_PRINT));
common_debug('ActivityPub Explorer: Invalid potential remote actor while grabbing remotely: '.$url. '. He returned the following: '.json_encode($res, JSON_UNESCAPED_SLASHES));
}
return false;