Skip to content

Commit 114e38a

Browse files
committed
feat(ocp): add Team Activity resource provider and TeamFolder root file id
Introduce ITeamActivityResourceProvider as an optional capability for ITeamResourceProvider implementations to resolve their Team resources into Activity scopes, backed by the new TeamActivityScope value object. Also expose the filecache root id on TeamFolder so Activity providers can reference team folder contents. Co-authored-by: Copilot <copilot@github.com> claude-sonnet-4.5 Signed-off-by: Stefan Lender <Stefan.Lender@dataport.de>
1 parent 525252a commit 114e38a

7 files changed

Lines changed: 151 additions & 3 deletions

File tree

‎lib/composer/composer/autoload_classmap.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,10 +1072,12 @@
10721072
'OCP\\TaskProcessing\\TaskTypes\\TextToTextSummary' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextSummary.php',
10731073
'OCP\\TaskProcessing\\TaskTypes\\TextToTextTopics' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextTopics.php',
10741074
'OCP\\TaskProcessing\\TaskTypes\\TextToTextTranslate' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextTranslate.php',
1075+
'OCP\\Teams\\ITeamActivityResourceProvider' => $baseDir . '/lib/public/Teams/ITeamActivityResourceProvider.php',
10751076
'OCP\\Teams\\ITeamFolderProvider' => $baseDir . '/lib/public/Teams/ITeamFolderProvider.php',
10761077
'OCP\\Teams\\ITeamManager' => $baseDir . '/lib/public/Teams/ITeamManager.php',
10771078
'OCP\\Teams\\ITeamResourceProvider' => $baseDir . '/lib/public/Teams/ITeamResourceProvider.php',
10781079
'OCP\\Teams\\Team' => $baseDir . '/lib/public/Teams/Team.php',
1080+
'OCP\\Teams\\TeamActivityScope' => $baseDir . '/lib/public/Teams/TeamActivityScope.php',
10791081
'OCP\\Teams\\TeamFolder' => $baseDir . '/lib/public/Teams/TeamFolder.php',
10801082
'OCP\\Teams\\TeamResource' => $baseDir . '/lib/public/Teams/TeamResource.php',
10811083
'OCP\\Template' => $baseDir . '/lib/public/Template.php',

‎lib/composer/composer/autoload_static.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,10 +1118,12 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
11181118
'OCP\\TaskProcessing\\TaskTypes\\TextToTextSummary' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextSummary.php',
11191119
'OCP\\TaskProcessing\\TaskTypes\\TextToTextTopics' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextTopics.php',
11201120
'OCP\\TaskProcessing\\TaskTypes\\TextToTextTranslate' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextTranslate.php',
1121+
'OCP\\Teams\\ITeamActivityResourceProvider' => __DIR__ . '/../../..' . '/lib/public/Teams/ITeamActivityResourceProvider.php',
11211122
'OCP\\Teams\\ITeamFolderProvider' => __DIR__ . '/../../..' . '/lib/public/Teams/ITeamFolderProvider.php',
11221123
'OCP\\Teams\\ITeamManager' => __DIR__ . '/../../..' . '/lib/public/Teams/ITeamManager.php',
11231124
'OCP\\Teams\\ITeamResourceProvider' => __DIR__ . '/../../..' . '/lib/public/Teams/ITeamResourceProvider.php',
11241125
'OCP\\Teams\\Team' => __DIR__ . '/../../..' . '/lib/public/Teams/Team.php',
1126+
'OCP\\Teams\\TeamActivityScope' => __DIR__ . '/../../..' . '/lib/public/Teams/TeamActivityScope.php',
11251127
'OCP\\Teams\\TeamFolder' => __DIR__ . '/../../..' . '/lib/public/Teams/TeamFolder.php',
11261128
'OCP\\Teams\\TeamResource' => __DIR__ . '/../../..' . '/lib/public/Teams/TeamResource.php',
11271129
'OCP\\Template' => __DIR__ . '/../../..' . '/lib/public/Template.php',
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/**
4+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
5+
* SPDX-License-Identifier: AGPL-3.0-or-later
6+
*/
7+
8+
namespace OCP\Teams;
9+
10+
/**
11+
* An optional Team resource provider capability for Team Activity.
12+
*
13+
* @since 36.0.0
14+
*/
15+
interface ITeamActivityResourceProvider extends ITeamResourceProvider {
16+
/**
17+
* Resolve Team resources into Activity objects visible to the current user.
18+
*
19+
* @param list<TeamResource> $resources Resources from this provider shared with the Team
20+
* @param string $userId The user the activity scopes are resolved for
21+
* @return list<TeamActivityScope>
22+
* @since 36.0.0
23+
*/
24+
public function getActivityScopes(array $resources, string $userId): array;
25+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/**
4+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
5+
* SPDX-License-Identifier: AGPL-3.0-or-later
6+
*/
7+
8+
namespace OCP\Teams;
9+
10+
/**
11+
* A set of Activity objects belonging to Team resources.
12+
*
13+
* @since 36.0.0
14+
*/
15+
class TeamActivityScope {
16+
/**
17+
* @param list<int> $objectIds
18+
* @since 36.0.0
19+
*/
20+
public function __construct(
21+
private string $objectType,
22+
private array $objectIds,
23+
) {
24+
if ($this->objectType === '') {
25+
throw new \InvalidArgumentException('Activity object type must not be empty');
26+
}
27+
foreach ($this->objectIds as $objectId) {
28+
if (!is_int($objectId) || $objectId <= 0) {
29+
throw new \InvalidArgumentException('Activity object IDs must be positive');
30+
}
31+
}
32+
$this->objectIds = array_values(array_unique($this->objectIds));
33+
}
34+
35+
/**
36+
* @since 36.0.0
37+
*/
38+
public function getObjectType(): string {
39+
return $this->objectType;
40+
}
41+
42+
/**
43+
* @return list<int>
44+
* @since 36.0.0
45+
*/
46+
public function getObjectIds(): array {
47+
return $this->objectIds;
48+
}
49+
}

‎lib/public/Teams/TeamFolder.php‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function __construct(
2525
private int $id,
2626
private string $mountPoint,
2727
private ?int $quota = null,
28+
private ?int $rootFileId = null,
2829
) {
2930
}
3031

@@ -53,7 +54,16 @@ public function getQuota(): ?int {
5354
}
5455

5556
/**
56-
* @return array{id: int, quota: int|null, mountPoint: string}
57+
* Return the filecache ID of the folder's root, when exposed by the provider.
58+
*
59+
* @since 36.0.0
60+
*/
61+
public function getRootFileId(): ?int {
62+
return $this->rootFileId;
63+
}
64+
65+
/**
66+
* @return array{id: int, quota: int|null, mountPoint: string, rootFileId: int|null}
5767
* @since 35.0.0
5868
*/
5969
#[\Override]
@@ -62,6 +72,7 @@ public function jsonSerialize(): array {
6272
'id' => $this->id,
6373
'quota' => $this->quota,
6474
'mountPoint' => $this->mountPoint,
75+
'rootFileId' => $this->rootFileId,
6576
];
6677
}
6778
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace Test\Teams;
11+
12+
use OCP\Teams\TeamActivityScope;
13+
use Test\TestCase;
14+
15+
class TeamActivityScopeTest extends TestCase {
16+
public function testGettersReturnConstructorValues(): void {
17+
$scope = new TeamActivityScope('files', [1, 2, 3]);
18+
19+
$this->assertSame('files', $scope->getObjectType());
20+
$this->assertSame([1, 2, 3], $scope->getObjectIds());
21+
}
22+
23+
public function testDeduplicatesObjectIds(): void {
24+
$scope = new TeamActivityScope('files', [1, 2, 2, 3, 1]);
25+
26+
$this->assertSame([1, 2, 3], $scope->getObjectIds());
27+
}
28+
29+
public function testRejectsEmptyObjectType(): void {
30+
$this->expectException(\InvalidArgumentException::class);
31+
32+
new TeamActivityScope('', [1]);
33+
}
34+
35+
public static function invalidObjectIdProvider(): array {
36+
return [
37+
'zero' => [0],
38+
'negative' => [-1],
39+
'non-integer' => ['1'],
40+
];
41+
}
42+
43+
/**
44+
* @dataProvider invalidObjectIdProvider
45+
*/
46+
public function testRejectsInvalidObjectIds(mixed $objectId): void {
47+
$this->expectException(\InvalidArgumentException::class);
48+
49+
new TeamActivityScope('files', [$objectId]);
50+
}
51+
}

‎tests/lib/Teams/TeamFolderTest.php‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,21 @@ public function testSerializesFolderIdentity(): void {
1919
$this->assertSame(42, $folder->getId());
2020
$this->assertSame('Engineering', $folder->getMountPoint());
2121
$this->assertNull($folder->getQuota());
22-
$this->assertSame(['id' => 42, 'quota' => null, 'mountPoint' => 'Engineering'], $folder->jsonSerialize());
22+
$this->assertNull($folder->getRootFileId());
23+
$this->assertSame(['id' => 42, 'quota' => null, 'mountPoint' => 'Engineering', 'rootFileId' => null], $folder->jsonSerialize());
2324
}
2425

2526
public function testSerializesFolderQuota(): void {
2627
$folder = new TeamFolder(42, 'Engineering', 1024);
2728

2829
$this->assertSame(1024, $folder->getQuota());
29-
$this->assertSame(['id' => 42, 'quota' => 1024, 'mountPoint' => 'Engineering'], $folder->jsonSerialize());
30+
$this->assertSame(['id' => 42, 'quota' => 1024, 'mountPoint' => 'Engineering', 'rootFileId' => null], $folder->jsonSerialize());
31+
}
32+
33+
public function testSerializesFolderRootFileId(): void {
34+
$folder = new TeamFolder(42, 'Engineering', 1024, 1337);
35+
36+
$this->assertSame(1337, $folder->getRootFileId());
37+
$this->assertSame(['id' => 42, 'quota' => 1024, 'mountPoint' => 'Engineering', 'rootFileId' => 1337], $folder->jsonSerialize());
3038
}
3139
}

0 commit comments

Comments
 (0)