Skip to content
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
18 changes: 17 additions & 1 deletion lib/Activity/DeckProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -47,6 +51,7 @@ public function __construct(IURLGenerator $urlGenerator, ActivityManager $activi
$this->l10nFactory = $l10n;
$this->config = $config;
$this->cardService = $cardService;
$this->circlesService = $circlesService;
}

/**
Expand Down Expand Up @@ -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',
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/Activity/DeckProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,6 +68,9 @@ class DeckProviderTest extends TestCase {
/** @var CardService|MockObject */
private $cardService;

/** @var CirclesService|MockObject */
private $circlesService;

/** @var string */
private $userId = 'admin';

Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Notification/NotificationHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct($uid) {
$this->uid = $uid;
}

public function getUID() {
public function getUID():string {
return $this->uid;
}
}
Expand Down