Actor is now created on first use of the app

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/9/head
Maxence Lange 2018-10-02 12:25:36 +02:00
rodzic f05f47807e
commit 0ab2dcd522
3 zmienionych plików z 24 dodań i 3 usunięć

Wyświetl plik

@ -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'],

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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);