Minor corrections

This commit is contained in:
Diogo Cordeiro 2018-07-09 00:07:14 +01:00
parent 167f88a602
commit f533ef2d32

View File

@ -1,4 +1,7 @@
<?php
use Profile;
/**
* GNU social - a federating social network
*
@ -39,6 +42,7 @@ class Activitypub_Discovery {
} else {
// Sometimes it is not true that the user is not locally available,
// mostly when it is a local user and URLs slightly changed
// e.g.: GS instance owner changed from standard urls to pretty urls
// (not sure if this is necessary, but anyway)
// Iff we really are in the same instance
@ -58,14 +62,20 @@ class Activitypub_Discovery {
$headers[] = 'User-Agent: GNUSocialBot v0.1 - https://gnu.io/social';
$response = $client->get ($url, $headers);
$this->response = json_decode ($response->getBody (), JSON_UNESCAPED_SLASHES);
if (!$response->isOk ())
ActivityPubReturn::error ("Invalid Actor URL", 404);
if (!$response->isOk()) {
throw new NoResultException ("Invalid Actor URL.");
}
return $this->storeProfile ();
}
public function storeProfile ()
private function storeProfile ()
{
$res = $this->response;
// Validate response
if (!isset ($res["url"], $res["nickname"], $res["display_name"], $res["summary"])) {
throw new NoProfileException("Invalid Actor URL.");
}
$profile = new Profile;
$profile->profileurl = $res["url"];
$profile->nickname = $res["nickname"];