Skip to content

Commit 3c79fe0

Browse files
authored
Merge pull request #7634 from nextcloud/backport/7630/stable33
[stable33] fix: show team names in activity feed
2 parents 0fe57d6 + 00765fc commit 3c79fe0

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

lib/Activity/DeckProvider.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use OCA\Deck\Db\Acl;
1111
use OCA\Deck\Service\CardService;
12+
use OCA\Deck\Service\CirclesService;
1213
use OCP\Activity\IEvent;
1314
use OCP\Activity\IProvider;
1415
use OCP\Comments\IComment;
@@ -38,7 +39,10 @@ class DeckProvider implements IProvider {
3839
/** @var CardService */
3940
private $cardService;
4041

41-
public function __construct(IURLGenerator $urlGenerator, ActivityManager $activityManager, IUserManager $userManager, ICommentsManager $commentsManager, IFactory $l10n, IConfig $config, $userId, CardService $cardService) {
42+
/** @var CirclesService */
43+
private $circlesService;
44+
45+
public function __construct(IURLGenerator $urlGenerator, ActivityManager $activityManager, IUserManager $userManager, ICommentsManager $commentsManager, IFactory $l10n, IConfig $config, $userId, CardService $cardService, CirclesService $circlesService) {
4246
$this->userId = $userId;
4347
$this->urlGenerator = $urlGenerator;
4448
$this->activityManager = $activityManager;
@@ -47,6 +51,7 @@ public function __construct(IURLGenerator $urlGenerator, ActivityManager $activi
4751
$this->l10nFactory = $l10n;
4852
$this->config = $config;
4953
$this->cardService = $cardService;
54+
$this->circlesService = $circlesService;
5055
}
5156

5257
/**
@@ -275,6 +280,17 @@ private function parseParamForAcl($subjectParams, $params) {
275280
'id' => $subjectParams['acl']['participant'],
276281
'name' => $user !== null ? $user->getDisplayName() : $subjectParams['acl']['participant']
277282
];
283+
} elseif ($subjectParams['acl']['type'] === Acl::PERMISSION_TYPE_CIRCLE) {
284+
$circle = $this->circlesService->getCircle($subjectParams['acl']['participant']);
285+
286+
// suppressing psalm because $circle is typed as Circle|null but psalm doesnt know about the OCA class
287+
// $circle->getName() will be defined when $circle is not null
288+
/** @psalm-suppress UndefinedMethod */
289+
$params['acl'] = [
290+
'type' => 'highlight',
291+
'id' => $subjectParams['acl']['participant'],
292+
'name' => $circle ? $circle->getName() : $subjectParams['acl']['participant']
293+
];
278294
} else {
279295
$params['acl'] = [
280296
'type' => 'highlight',

tests/unit/Activity/DeckProviderTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use OCA\Deck\Db\Acl;
2929
use OCA\Deck\Db\Card;
3030
use OCA\Deck\Service\CardService;
31+
use OCA\Deck\Service\CirclesService;
3132
use OCP\Activity\IEvent;
3233
use OCP\Comments\IComment;
3334
use OCP\Comments\ICommentsManager;
@@ -67,6 +68,9 @@ class DeckProviderTest extends TestCase {
6768
/** @var CardService|MockObject */
6869
private $cardService;
6970

71+
/** @var CirclesService|MockObject */
72+
private $circlesService;
73+
7074
/** @var string */
7175
private $userId = 'admin';
7276

@@ -79,7 +83,8 @@ public function setUp(): void {
7983
$this->l10nFactory = $this->createMock(IFactory::class);
8084
$this->config = $this->createMock(IConfig::class);
8185
$this->cardService = $this->createMock(CardService::class);
82-
$this->provider = new DeckProvider($this->urlGenerator, $this->activityManager, $this->userManager, $this->commentsManager, $this->l10nFactory, $this->config, $this->userId, $this->cardService);
86+
$this->circlesService = $this->createMock(CirclesService::class);
87+
$this->provider = new DeckProvider($this->urlGenerator, $this->activityManager, $this->userManager, $this->commentsManager, $this->l10nFactory, $this->config, $this->userId, $this->cardService, $this->circlesService);
8388

8489
$this->activityManager->method('canSeeCardActivity')->willReturn(true);
8590
$this->activityManager->method('canSeeBoardActivity')->willReturn(true);

tests/unit/Notification/NotificationHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct($uid) {
5050
$this->uid = $uid;
5151
}
5252

53-
public function getUID() {
53+
public function getUID():string {
5454
return $this->uid;
5555
}
5656
}

0 commit comments

Comments
 (0)