summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-10-05 15:57:31 -0100
committerMaxence Lange <maxence@artificial-owl.com>2019-10-05 15:57:31 -0100
commitdc2141c6def885b0c8741157fa2db97662a3f274 (patch)
tree769d203b96bed7365cfc92e9223890cc5aade7f2 /lib
parent0a7c5c717f51c7fecdcd644b8faaff06dbdbedcc (diff)
accepting request on actor id
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/webfinger.php41
1 files changed, 34 insertions, 7 deletions
diff --git a/lib/webfinger.php b/lib/webfinger.php
index b6113890..e8bbdabb 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,15 +88,30 @@ try {
$cacheActorService->getFromLocalAccount($username);
} catch (Exception $e) {
- OC::$server->getLogger()
- ->log(1, 'Exception on webfinger - ' . $e->getMessage());
- http_response_code(404);
- exit;
+ 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;
+ }
}
-$href = $configService->getSocialUrl() . '@' . $username;
-// $urlGenerator->linkToRoute('social.ActivityPub.actorAlias', ['username' => $username])
-//);
+try {
+ $href = $configService->getSocialUrl() . '@' . $username;
+} catch (SocialAppConfigException $e) {
+ exit;
+}
if (substr($href, -1) === '/') {
$href = substr($href, 0, -1);