diff --git a/lib/Activity/DeckProvider.php b/lib/Activity/DeckProvider.php index f18842f48..8dbff70e1 100644 --- a/lib/Activity/DeckProvider.php +++ b/lib/Activity/DeckProvider.php @@ -9,6 +9,7 @@ use OCA\Deck\Db\Acl; use OCA\Deck\Service\CardService; +use OCA\Deck\Service\CirclesService; use OCP\Activity\IEvent; use OCP\Activity\IProvider; use OCP\Comments\IComment; @@ -38,7 +39,10 @@ class DeckProvider implements IProvider { /** @var CardService */ private $cardService; - public function __construct(IURLGenerator $urlGenerator, ActivityManager $activityManager, IUserManager $userManager, ICommentsManager $commentsManager, IFactory $l10n, IConfig $config, $userId, CardService $cardService) { + /** @var CirclesService */ + private $circlesService; + + public function __construct(IURLGenerator $urlGenerator, ActivityManager $activityManager, IUserManager $userManager, ICommentsManager $commentsManager, IFactory $l10n, IConfig $config, $userId, CardService $cardService, CirclesService $circlesService) { $this->userId = $userId; $this->urlGenerator = $urlGenerator; $this->activityManager = $activityManager; @@ -47,6 +51,7 @@ public function __construct(IURLGenerator $urlGenerator, ActivityManager $activi $this->l10nFactory = $l10n; $this->config = $config; $this->cardService = $cardService; + $this->circlesService = $circlesService; } /** @@ -275,6 +280,17 @@ private function parseParamForAcl($subjectParams, $params) { 'id' => $subjectParams['acl']['participant'], 'name' => $user !== null ? $user->getDisplayName() : $subjectParams['acl']['participant'] ]; + } elseif ($subjectParams['acl']['type'] === Acl::PERMISSION_TYPE_CIRCLE) { + $circle = $this->circlesService->getCircle($subjectParams['acl']['participant']); + + // suppressing psalm because $circle is typed as Circle|null but psalm doesnt know about the OCA class + // $circle->getName() will be defined when $circle is not null + /** @psalm-suppress UndefinedMethod */ + $params['acl'] = [ + 'type' => 'highlight', + 'id' => $subjectParams['acl']['participant'], + 'name' => $circle ? $circle->getName() : $subjectParams['acl']['participant'] + ]; } else { $params['acl'] = [ 'type' => 'highlight', diff --git a/tests/unit/Activity/DeckProviderTest.php b/tests/unit/Activity/DeckProviderTest.php index c82520087..2f7946f87 100644 --- a/tests/unit/Activity/DeckProviderTest.php +++ b/tests/unit/Activity/DeckProviderTest.php @@ -28,6 +28,7 @@ use OCA\Deck\Db\Acl; use OCA\Deck\Db\Card; use OCA\Deck\Service\CardService; +use OCA\Deck\Service\CirclesService; use OCP\Activity\IEvent; use OCP\Comments\IComment; use OCP\Comments\ICommentsManager; @@ -67,6 +68,9 @@ class DeckProviderTest extends TestCase { /** @var CardService|MockObject */ private $cardService; + /** @var CirclesService|MockObject */ + private $circlesService; + /** @var string */ private $userId = 'admin'; @@ -79,7 +83,8 @@ public function setUp(): void { $this->l10nFactory = $this->createMock(IFactory::class); $this->config = $this->createMock(IConfig::class); $this->cardService = $this->createMock(CardService::class); - $this->provider = new DeckProvider($this->urlGenerator, $this->activityManager, $this->userManager, $this->commentsManager, $this->l10nFactory, $this->config, $this->userId, $this->cardService); + $this->circlesService = $this->createMock(CirclesService::class); + $this->provider = new DeckProvider($this->urlGenerator, $this->activityManager, $this->userManager, $this->commentsManager, $this->l10nFactory, $this->config, $this->userId, $this->cardService, $this->circlesService); $this->activityManager->method('canSeeCardActivity')->willReturn(true); $this->activityManager->method('canSeeBoardActivity')->willReturn(true); diff --git a/tests/unit/Notification/NotificationHelperTest.php b/tests/unit/Notification/NotificationHelperTest.php index 30483f11a..3ac7d3c78 100644 --- a/tests/unit/Notification/NotificationHelperTest.php +++ b/tests/unit/Notification/NotificationHelperTest.php @@ -50,7 +50,7 @@ public function __construct($uid) { $this->uid = $uid; } - public function getUID() { + public function getUID():string { return $this->uid; } }