Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use RequestUtil for getting actor #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Api/Controllers/CreateDoorkeyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace FoF\Doorman\Api\Controllers;

use Flarum\Api\Controller\AbstractCreateController;
use Flarum\Http\RequestUtil;
use FoF\Doorman\Api\Serializers\DoorkeySerializer;
use FoF\Doorman\Commands\CreateDoorkey;
use Illuminate\Contracts\Bus\Dispatcher;
Expand Down Expand Up @@ -46,8 +47,10 @@ public function __construct(Dispatcher $bus)
*/
protected function data(ServerRequestInterface $request, Document $document)
{
$actor = RequestUtil::getActor($request);

return $this->bus->dispatch(
new CreateDoorkey($request->getAttribute('actor'), Arr::get($request->getParsedBody(), 'data', []))
new CreateDoorkey($actor, Arr::get($request->getParsedBody(), 'data', []))
);
}
}
5 changes: 4 additions & 1 deletion src/Api/Controllers/DeleteDoorkeyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace FoF\Doorman\Api\Controllers;

use Flarum\Api\Controller\AbstractDeleteController;
use Flarum\Http\RequestUtil;
use FoF\Doorman\Commands\DeleteDoorkey;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Support\Arr;
Expand All @@ -39,8 +40,10 @@ public function __construct(Dispatcher $bus)
*/
protected function delete(ServerRequestInterface $request)
{
$actor = RequestUtil::getActor($request);

$this->bus->dispatch(
new DeleteDoorkey(Arr::get($request->getQueryParams(), 'id'), $request->getAttribute('actor'))
new DeleteDoorkey(Arr::get($request->getQueryParams(), 'id'), $actor)
);
}
}
5 changes: 4 additions & 1 deletion src/Api/Controllers/UpdateDoorkeyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace FoF\Doorman\Api\Controllers;

use Flarum\Api\Controller\AbstractShowController;
use Flarum\Http\RequestUtil;
use FoF\Doorman\Api\Serializers\DoorkeySerializer;
use FoF\Doorman\Commands\EditDoorkey;
use Illuminate\Contracts\Bus\Dispatcher;
Expand Down Expand Up @@ -46,8 +47,10 @@ public function __construct(Dispatcher $bus)
*/
protected function data(ServerRequestInterface $request, Document $document)
{
$actor = RequestUtil::getActor($request);

return $this->bus->dispatch(
new EditDoorkey(Arr::get($request->getQueryParams(), 'id'), $request->getAttribute('actor'), Arr::get($request->getParsedBody(), 'data', []))
new EditDoorkey(Arr::get($request->getQueryParams(), 'id'), $actor, Arr::get($request->getParsedBody(), 'data', []))
);
}
}
Loading