kopia lustrzana https://github.com/nextcloud/social
Merge pull request #122 from nextcloud-gmbh/more-404
returns 404 on non existant user/avatarpull/123/head^2
commit
236caae524
|
@ -12,12 +12,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/daita/my-small-php-tools.git",
|
||||
"reference": "36ea85a58ceb57a521c8f5a43effb4a7330e7b4c"
|
||||
"reference": "7a61e966ac2a01db6fd0096f77620a7db978af18"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/36ea85a58ceb57a521c8f5a43effb4a7330e7b4c",
|
||||
"reference": "36ea85a58ceb57a521c8f5a43effb4a7330e7b4c",
|
||||
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/7a61e966ac2a01db6fd0096f77620a7db978af18",
|
||||
"reference": "7a61e966ac2a01db6fd0096f77620a7db978af18",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -40,7 +40,7 @@
|
|||
}
|
||||
],
|
||||
"description": "My small PHP Tools",
|
||||
"time": "2018-11-29T16:46:38+00:00"
|
||||
"time": "2018-12-04T10:09:31+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
|
|
@ -43,6 +43,7 @@ use OCA\Social\Service\ActorService;
|
|||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\NotFoundResponse;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\IRequest;
|
||||
|
||||
|
@ -133,7 +134,8 @@ class ActivityPubController extends Controller {
|
|||
|
||||
return $this->directSuccess($actor);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
http_response_code(404);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +183,7 @@ class ActivityPubController extends Controller {
|
|||
|
||||
return $this->success([]);
|
||||
} catch (SignatureIsGoneException $e) {
|
||||
return $this->fail($e, [], Http::STATUS_GONE);
|
||||
return $this->fail($e, [], Http::STATUS_GONE, false);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ use OCA\Social\Service\ActorService;
|
|||
use OCA\Social\Service\MiscService;
|
||||
use OCA\Social\Service\PostService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Http\FileDisplayResponse;
|
||||
use OCP\AppFramework\Http\NotFoundResponse;
|
||||
|
@ -537,12 +538,13 @@ class LocalController extends Controller {
|
|||
|
||||
$response = new FileDisplayResponse($document);
|
||||
$response->cacheFor(86400);
|
||||
return $response;
|
||||
}
|
||||
|
||||
return new NotFoundResponse();
|
||||
return $response;
|
||||
} else {
|
||||
throw new InvalidResourceException('no avatar for this Actor');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
return $this->fail($e, [], Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ declare(strict_types=1);
|
|||
namespace OCA\Social\Service\ActivityPub;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use Exception;
|
||||
use OCA\Social\Db\CacheActorsRequest;
|
||||
|
@ -140,6 +141,7 @@ class PersonService implements ICoreService {
|
|||
* @throws SocialAppConfigException
|
||||
* @throws UrlCloudException
|
||||
* @throws Request410Exception
|
||||
* @throws MalformedArrayException
|
||||
*/
|
||||
public function getFromId(string $id, bool $refresh = false): Person {
|
||||
|
||||
|
@ -182,6 +184,7 @@ class PersonService implements ICoreService {
|
|||
* @throws SocialAppConfigException
|
||||
* @throws UrlCloudException
|
||||
* @throws Request410Exception
|
||||
* @throws MalformedArrayException
|
||||
*/
|
||||
public function getFromAccount(string $account, bool $retrieve = true): Person {
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace OCA\Social\Service;
|
|||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\ArrayNotFoundException;
|
||||
use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
|
||||
use daita\MySmallPhpTools\Model\Request;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use daita\MySmallPhpTools\Traits\TPathTools;
|
||||
|
@ -81,6 +82,7 @@ class InstanceService {
|
|||
* @throws RequestException
|
||||
* @throws InvalidResourceException
|
||||
* @throws Request410Exception
|
||||
* @throws MalformedArrayException
|
||||
*/
|
||||
public function retrieveAccount(string $account) {
|
||||
$account = $this->withoutBeginAt($account);
|
||||
|
@ -115,9 +117,11 @@ class InstanceService {
|
|||
* @return mixed
|
||||
* @throws RequestException
|
||||
* @throws Request410Exception
|
||||
* @throws MalformedArrayException
|
||||
*/
|
||||
public function retrieveObject($id) {
|
||||
$url = parse_url($id);
|
||||
$this->mustContains(['path', 'host'], $url);
|
||||
$request = new Request($url['path'], Request::TYPE_GET);
|
||||
$request->setAddress($url['host']);
|
||||
|
||||
|
|
|
@ -28,8 +28,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OCA\Social\Service\ActorService;
|
||||
use OCP\AppFramework\QueryException;
|
||||
|
||||
require_once(__DIR__ . '/../appinfo/autoload.php');
|
||||
|
||||
|
||||
if (!array_key_exists('resource', $_GET)) {
|
||||
echo 'missing resource';
|
||||
exit();
|
||||
|
@ -47,6 +53,16 @@ if ($type !== 'acct') {
|
|||
|
||||
|
||||
$username = substr($account, 0, strrpos($account, '@'));
|
||||
|
||||
/** @var ActorService $actorService */
|
||||
try {
|
||||
$actorService = \OC::$server->query(ActorService::class);
|
||||
$actorService->getActor($username);
|
||||
} catch (Exception $e) {
|
||||
http_response_code(404);
|
||||
exit;
|
||||
}
|
||||
|
||||
$finger = [
|
||||
'subject' => $subject,
|
||||
'links' => [
|
||||
|
@ -60,6 +76,7 @@ $finger = [
|
|||
]
|
||||
];
|
||||
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
echo json_encode($finger);
|
||||
|
|
Ładowanie…
Reference in New Issue