diff --git a/appinfo/routes.php b/appinfo/routes.php index dc3d19f9..e1ba5193 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -11,7 +11,7 @@ return [ 'routes' => [ ['name' => 'Navigation#navigate', 'url' => '/', 'verb' => 'GET'], - ['name' => 'Account#create', 'url' => '/local/account/{username}', 'verb' => 'POST'], +// ['name' => 'Account#create', 'url' => '/local/account/{username}', 'verb' => 'POST'], ['name' => 'ActivityPub#sharedInbox', 'url' => '/inbox', 'verb' => 'POST'], ['name' => 'ActivityPub#actor', 'url' => '/users/{username}', 'verb' => 'GET'], diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php index e6e35a0f..b3cbc543 100644 --- a/lib/Controller/NavigationController.php +++ b/lib/Controller/NavigationController.php @@ -30,7 +30,10 @@ declare(strict_types=1); namespace OCA\Social\Controller; +use OC\User\NoUserException; use OCA\Social\AppInfo\Application; +use OCA\Social\Exceptions\AccountAlreadyExistsException; +use OCA\Social\Service\ActorService; use OCA\Social\Service\MiscService; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; @@ -40,12 +43,18 @@ use OCP\IURLGenerator; class NavigationController extends Controller { + /** @var string */ + private $userId; + /** @var IConfig */ private $config; /** @var IURLGenerator */ private $urlGenerator; + /** @var ActorService */ + private $actorService; + /** @var MiscService */ private $miscService; @@ -54,18 +63,22 @@ class NavigationController extends Controller { * NavigationController constructor. * * @param IRequest $request + * @param string $userId * @param IConfig $config * @param IURLGenerator $urlGenerator * @param MiscService $miscService */ public function __construct( - IRequest $request, IConfig $config, IURLGenerator $urlGenerator, MiscService $miscService + IRequest $request, string $userId, IConfig $config, IURLGenerator $urlGenerator, + ActorService $actorService, MiscService $miscService ) { parent::__construct(Application::APP_NAME, $request); + $this->userId = $userId; $this->config = $config; $this->urlGenerator = $urlGenerator; + $this->actorService = $actorService; $this->miscService = $miscService; } @@ -78,10 +91,17 @@ class NavigationController extends Controller { * @NoSubAdminRequired * * @return TemplateResponse + * @throws NoUserException */ public function navigate(): TemplateResponse { $data = []; + try { + $this->actorService->createActor($this->userId, $this->userId); + } catch (AccountAlreadyExistsException $e) { + // we do nothing + } + return new TemplateResponse(Application::APP_NAME, 'main', $data); } diff --git a/lib/Service/ActorService.php b/lib/Service/ActorService.php index 1f374ea3..f0de418b 100644 --- a/lib/Service/ActorService.php +++ b/lib/Service/ActorService.php @@ -198,7 +198,6 @@ class ActorService { $this->miscService->confirmUserId($userId); $this->checkActorUsername($username); - $this->configService->setCoreValue('public_webfinger', 'social/lib/webfinger.php'); try { $this->actorsRequest->getFromUsername($username); @@ -214,6 +213,8 @@ class ActorService { /* we do nohtin */ } + $this->configService->setCoreValue('public_webfinger', 'social/lib/webfinger.php'); + $actor = new Actor(); $actor->setUserId($userId); $actor->setPreferredUsername($username);