kopia lustrzana https://github.com/nextcloud/social
returns 404 on non existant user/avatar
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/122/head
rodzic
c45cfe6b49
commit
25550d5d4e
|
@ -12,12 +12,12 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/daita/my-small-php-tools.git",
|
"url": "https://github.com/daita/my-small-php-tools.git",
|
||||||
"reference": "36ea85a58ceb57a521c8f5a43effb4a7330e7b4c"
|
"reference": "523adb71b0e12fd678909aeef45ef2c0f612e02a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/36ea85a58ceb57a521c8f5a43effb4a7330e7b4c",
|
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/523adb71b0e12fd678909aeef45ef2c0f612e02a",
|
||||||
"reference": "36ea85a58ceb57a521c8f5a43effb4a7330e7b4c",
|
"reference": "523adb71b0e12fd678909aeef45ef2c0f612e02a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "My small PHP Tools",
|
"description": "My small PHP Tools",
|
||||||
"time": "2018-11-29T16:46:38+00:00"
|
"time": "2018-12-04T09:44:36+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
|
|
|
@ -43,6 +43,7 @@ use OCA\Social\Service\ActorService;
|
||||||
use OCA\Social\Service\ImportService;
|
use OCA\Social\Service\ImportService;
|
||||||
use OCA\Social\Service\MiscService;
|
use OCA\Social\Service\MiscService;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
|
use OCP\AppFramework\Http\NotFoundResponse;
|
||||||
use OCP\AppFramework\Http\Response;
|
use OCP\AppFramework\Http\Response;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
|
||||||
|
@ -133,7 +134,8 @@ class ActivityPubController extends Controller {
|
||||||
|
|
||||||
return $this->directSuccess($actor);
|
return $this->directSuccess($actor);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return $this->fail($e);
|
http_response_code(404);
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -537,13 +537,14 @@ class LocalController extends Controller {
|
||||||
|
|
||||||
$response = new FileDisplayResponse($document);
|
$response = new FileDisplayResponse($document);
|
||||||
$response->cacheFor(86400);
|
$response->cacheFor(86400);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new NotFoundResponse();
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return $this->fail($e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
http_response_code(404);
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ declare(strict_types=1);
|
||||||
namespace OCA\Social\Service\ActivityPub;
|
namespace OCA\Social\Service\ActivityPub;
|
||||||
|
|
||||||
|
|
||||||
|
use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
|
||||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||||
use Exception;
|
use Exception;
|
||||||
use OCA\Social\Db\CacheActorsRequest;
|
use OCA\Social\Db\CacheActorsRequest;
|
||||||
|
@ -140,6 +141,7 @@ class PersonService implements ICoreService {
|
||||||
* @throws SocialAppConfigException
|
* @throws SocialAppConfigException
|
||||||
* @throws UrlCloudException
|
* @throws UrlCloudException
|
||||||
* @throws Request410Exception
|
* @throws Request410Exception
|
||||||
|
* @throws MalformedArrayException
|
||||||
*/
|
*/
|
||||||
public function getFromId(string $id, bool $refresh = false): Person {
|
public function getFromId(string $id, bool $refresh = false): Person {
|
||||||
|
|
||||||
|
@ -182,6 +184,7 @@ class PersonService implements ICoreService {
|
||||||
* @throws SocialAppConfigException
|
* @throws SocialAppConfigException
|
||||||
* @throws UrlCloudException
|
* @throws UrlCloudException
|
||||||
* @throws Request410Exception
|
* @throws Request410Exception
|
||||||
|
* @throws MalformedArrayException
|
||||||
*/
|
*/
|
||||||
public function getFromAccount(string $account, bool $retrieve = true): Person {
|
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\ArrayNotFoundException;
|
||||||
|
use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
|
||||||
use daita\MySmallPhpTools\Model\Request;
|
use daita\MySmallPhpTools\Model\Request;
|
||||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||||
use daita\MySmallPhpTools\Traits\TPathTools;
|
use daita\MySmallPhpTools\Traits\TPathTools;
|
||||||
|
@ -81,6 +82,7 @@ class InstanceService {
|
||||||
* @throws RequestException
|
* @throws RequestException
|
||||||
* @throws InvalidResourceException
|
* @throws InvalidResourceException
|
||||||
* @throws Request410Exception
|
* @throws Request410Exception
|
||||||
|
* @throws MalformedArrayException
|
||||||
*/
|
*/
|
||||||
public function retrieveAccount(string $account) {
|
public function retrieveAccount(string $account) {
|
||||||
$account = $this->withoutBeginAt($account);
|
$account = $this->withoutBeginAt($account);
|
||||||
|
@ -115,9 +117,11 @@ class InstanceService {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws RequestException
|
* @throws RequestException
|
||||||
* @throws Request410Exception
|
* @throws Request410Exception
|
||||||
|
* @throws MalformedArrayException
|
||||||
*/
|
*/
|
||||||
public function retrieveObject($id) {
|
public function retrieveObject($id) {
|
||||||
$url = parse_url($id);
|
$url = parse_url($id);
|
||||||
|
$this->mustContains(['path', 'host'], $url);
|
||||||
$request = new Request($url['path'], Request::TYPE_GET);
|
$request = new Request($url['path'], Request::TYPE_GET);
|
||||||
$request->setAddress($url['host']);
|
$request->setAddress($url['host']);
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,14 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCA\Social;
|
namespace OCA\Social;
|
||||||
|
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use OCA\Social\Service\ActorService;
|
||||||
|
use OCP\AppFramework\QueryException;
|
||||||
|
|
||||||
require_once(__DIR__ . '/../appinfo/autoload.php');
|
require_once(__DIR__ . '/../appinfo/autoload.php');
|
||||||
|
|
||||||
|
|
||||||
if (!array_key_exists('resource', $_GET)) {
|
if (!array_key_exists('resource', $_GET)) {
|
||||||
echo 'missing resource';
|
echo 'missing resource';
|
||||||
exit();
|
exit();
|
||||||
|
@ -47,6 +53,16 @@ if ($type !== 'acct') {
|
||||||
|
|
||||||
|
|
||||||
$username = substr($account, 0, strrpos($account, '@'));
|
$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 = [
|
$finger = [
|
||||||
'subject' => $subject,
|
'subject' => $subject,
|
||||||
'links' => [
|
'links' => [
|
||||||
|
@ -60,6 +76,7 @@ $finger = [
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
echo json_encode($finger);
|
echo json_encode($finger);
|
||||||
|
|
Ładowanie…
Reference in New Issue