Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2021-03-30 13:45:04 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2021-03-30 19:06:51 +0300
commit117aaa73cf4a9da159de28b8ad48eb7acdab7010 (patch)
tree2a33d5983a50ec912d77d0d54c259aae450c7180 /lib/Controller
parent58d4234f85864a9bff77c19d3fc6b3b3cf12737a (diff)
Cleanup aliases logic
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'lib/Controller')
-rw-r--r--lib/Controller/AliasesController.php21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/Controller/AliasesController.php b/lib/Controller/AliasesController.php
index ca9d61589..b7475affa 100644
--- a/lib/Controller/AliasesController.php
+++ b/lib/Controller/AliasesController.php
@@ -23,30 +23,29 @@ declare(strict_types=1);
namespace OCA\Mail\Controller;
+use OCA\Mail\Exception\ClientException;
use OCA\Mail\Exception\NotImplemented;
use OCA\Mail\Service\AliasesService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;
-use OCP\IUser;
-use OCP\IUserSession;
class AliasesController extends Controller {
/** @var AliasesService */
private $aliasService;
- /** @var IUser */
- private $currentUser;
+ /** @var string */
+ private $currentUserId;
public function __construct(string $appName,
IRequest $request,
AliasesService $aliasesService,
- IUserSession $userSession) {
+ string $UserId) {
parent::__construct($appName, $request);
$this->aliasService = $aliasesService;
- $this->currentUser = $userSession->getUser();
+ $this->currentUserId = $UserId;
}
/**
@@ -58,7 +57,7 @@ class AliasesController extends Controller {
* @return JSONResponse
*/
public function index(int $accountId): JSONResponse {
- return new JSONResponse($this->aliasService->findAll($accountId, $this->currentUser->getUID()));
+ return new JSONResponse($this->aliasService->findAll($accountId, $this->currentUserId));
}
/**
@@ -85,7 +84,7 @@ class AliasesController extends Controller {
* @return JSONResponse
*/
public function destroy(int $id): JSONResponse {
- return new JSONResponse($this->aliasService->delete($id, $this->currentUser->getUID()));
+ return new JSONResponse($this->aliasService->delete($id, $this->currentUserId));
}
/**
@@ -97,8 +96,12 @@ class AliasesController extends Controller {
* @param string $aliasName
*
* @return JSONResponse
+ * @throws ClientException
*/
public function create(int $accountId, string $alias, string $aliasName): JSONResponse {
- return new JSONResponse($this->aliasService->create($accountId, $alias, $aliasName), Http::STATUS_CREATED);
+ return new JSONResponse(
+ $this->aliasService->create($this->currentUserId, $accountId, $alias, $aliasName),
+ Http::STATUS_CREATED
+ );
}
}