fix: generate fixed link for activity emails

Signed-off-by: Luka Trovic <luka@nextcloud.com>

fix: generate fixed link for activity emails

Signed-off-by: Luka Trovic <luka@nextcloud.com>

Fix tests

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Luka Trovic
2022-02-28 10:39:04 +01:00
committed by backportbot[bot]
parent 18babccfe1
commit 2d8bb1e654
9 changed files with 104 additions and 10 deletions

View File

@@ -34,12 +34,20 @@ use OCP\IInitialStateService;
use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Controller;
use OCA\Deck\Db\CardMapper;
use OCP\IURLGenerator;
use \OCP\AppFramework\Http\RedirectResponse;
use OCA\Deck\Db\Acl;
use OCA\Deck\Service\CardService;
class PageController extends Controller {
private $permissionService;
private $initialState;
private $configService;
private $eventDispatcher;
private $cardMapper;
private $urlGenerator;
private $cardService;
public function __construct(
$AppName,
@@ -47,7 +55,10 @@ class PageController extends Controller {
PermissionService $permissionService,
IInitialStateService $initialStateService,
ConfigService $configService,
IEventDispatcher $eventDispatcher
IEventDispatcher $eventDispatcher,
CardMapper $cardMapper,
IURLGenerator $urlGenerator,
CardService $cardService
) {
parent::__construct($AppName, $request);
@@ -55,6 +66,9 @@ class PageController extends Controller {
$this->initialState = $initialStateService;
$this->configService = $configService;
$this->eventDispatcher = $eventDispatcher;
$this->cardMapper = $cardMapper;
$this->urlGenerator = $urlGenerator;
$this->cardService = $cardService;
}
/**
@@ -85,4 +99,17 @@ class PageController extends Controller {
return $response;
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function redirectToCard($cardId): RedirectResponse {
try {
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
return new RedirectResponse($this->cardService->getCardUrl($cardId));
} catch (\Exception $e) {
return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('deck.page.index'));
}
}
}