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 Julius Härtl
parent 4b622d85ee
commit 165375fbab
9 changed files with 104 additions and 10 deletions

View File

@@ -50,6 +50,7 @@ use OCA\Deck\Db\BoardMapper;
use OCA\Deck\Db\LabelMapper;
use OCP\IUserManager;
use OCA\Deck\BadRequestException;
use OCP\IURLGenerator;
class BoardService {
private $boardMapper;
@@ -68,8 +69,8 @@ class BoardService {
private $activityManager;
private $eventDispatcher;
private $changeHelper;
private $boardsCache = null;
private $urlGenerator;
public function __construct(
@@ -87,6 +88,7 @@ class BoardService {
ActivityManager $activityManager,
IEventDispatcher $eventDispatcher,
ChangeHelper $changeHelper,
IURLGenerator $urlGenerator,
$userId
) {
$this->boardMapper = $boardMapper;
@@ -104,6 +106,7 @@ class BoardService {
$this->eventDispatcher = $eventDispatcher;
$this->changeHelper = $changeHelper;
$this->userId = $userId;
$this->urlGenerator = $urlGenerator;
}
/**
@@ -697,4 +700,8 @@ class BoardService {
}
$board->setUsers(array_values($boardUsers));
}
public function getBoardUrl($endpoint) {
return $this->urlGenerator->linkToRouteAbsolute('deck.page.index') . '#' . $endpoint;
}
}

View File

@@ -46,6 +46,7 @@ use OCA\Deck\BadRequestException;
use OCP\Comments\ICommentsManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUserManager;
use OCP\IURLGenerator;
class CardService {
private $cardMapper;
@@ -63,6 +64,7 @@ class CardService {
private $changeHelper;
private $eventDispatcher;
private $userManager;
private $urlGenerator;
public function __construct(
CardMapper $cardMapper,
@@ -79,6 +81,7 @@ class CardService {
IUserManager $userManager,
ChangeHelper $changeHelper,
IEventDispatcher $eventDispatcher,
IURLGenerator $urlGenerator,
$userId
) {
$this->cardMapper = $cardMapper;
@@ -96,6 +99,7 @@ class CardService {
$this->changeHelper = $changeHelper;
$this->eventDispatcher = $eventDispatcher;
$this->currentUser = $userId;
$this->urlGenerator = $urlGenerator;
}
public function enrich($card) {
@@ -602,4 +606,14 @@ class CardService {
$this->eventDispatcher->dispatchTyped(new CardUpdatedEvent($card));
}
public function getCardUrl($cardId) {
$boardId = $this->cardMapper->findBoardId($cardId);
return $this->urlGenerator->linkToRouteAbsolute('deck.page.index') . "#/board/$boardId/card/$cardId";
}
public function getRedirectUrlForCard($cardId) {
return $this->urlGenerator->linkToRouteAbsolute('deck.page.index') . "card/$cardId";
}
}