diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2019-10-05 15:59:04 -0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-05 15:59:04 -0100 |
commit | 38fc1037620a6dfb5168c7de8061f243ce4967c2 (patch) | |
tree | 108adc617d79d702e19824a2217876767429658b | |
parent | 0a7c5c717f51c7fecdcd644b8faaff06dbdbedcc (diff) | |
parent | 80c44ad7739d0ebe6a24ca177a9fca0fb3056c25 (diff) |
Merge pull request #788 from nextcloud/feature/noid/webfinger-on-actorid
accepting request on actor id
-rw-r--r-- | lib/webfinger.php | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/lib/webfinger.php b/lib/webfinger.php index b6113890..499dfac4 100644 --- a/lib/webfinger.php +++ b/lib/webfinger.php @@ -31,9 +31,11 @@ namespace OCA\Social; use Exception; use OC; +use OCA\Social\Exceptions\SocialAppConfigException; use OCA\Social\Service\CacheActorService; use OCA\Social\Service\ConfigService; use OCA\Social\Service\FediverseService; +use OCP\AppFramework\QueryException; require_once(__DIR__ . '/../appinfo/autoload.php'); @@ -57,10 +59,20 @@ if (strpos($subject, 'acct:') === 0) { list($username, $instance) = explode('@', $account); try { + /** @var CacheActorService $cacheActorService */ $cacheActorService = OC::$server->query(CacheActorService::class); + /** @var FediverseService $fediverseService */ $fediverseService = OC::$server->query(FediverseService::class); + /** @var ConfigService $configService */ $configService = OC::$server->query(ConfigService::class); +} catch (QueryException $e) { + OC::$server->getLogger() + ->log(1, 'QueryException - ' . $e->getMessage()); + http_response_code(404); + exit; +} +try { $fediverseService->jailed(); if ($configService->getSocialAddress() !== $instance) { @@ -76,16 +88,32 @@ try { $cacheActorService->getFromLocalAccount($username); } catch (Exception $e) { - OC::$server->getLogger() - ->log(1, 'Exception on webfinger - ' . $e->getMessage()); + if ($type !== '') { + OC::$server->getLogger() + ->log(1, 'Exception on webfinger/fromAccount - ' . $e->getMessage()); + http_response_code(404); + exit; + } + + try { + $fromId = $cacheActorService->getFromId($subject); + $instance = $configService->getSocialAddress(); + $username = $fromId->getPreferredUsername(); + } catch (Exception $e) { + OC::$server->getLogger() + ->log(1, 'Exception on webfinger/fromId - ' . $e->getMessage()); + http_response_code(404); + exit; + } +} + +try { + $href = $configService->getSocialUrl() . '@' . $username; +} catch (SocialAppConfigException $e) { http_response_code(404); exit; } -$href = $configService->getSocialUrl() . '@' . $username; -// $urlGenerator->linkToRoute('social.ActivityPub.actorAlias', ['username' => $username]) -//); - if (substr($href, -1) === '/') { $href = substr($href, 0, -1); } |