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
2 changes: 2 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1072,10 +1072,12 @@
'OCP\\TaskProcessing\\TaskTypes\\TextToTextSummary' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextSummary.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextTopics' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextTopics.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextTranslate' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextTranslate.php',
'OCP\\Teams\\ITeamActivityResourceProvider' => $baseDir . '/lib/public/Teams/ITeamActivityResourceProvider.php',
'OCP\\Teams\\ITeamFolderProvider' => $baseDir . '/lib/public/Teams/ITeamFolderProvider.php',
'OCP\\Teams\\ITeamManager' => $baseDir . '/lib/public/Teams/ITeamManager.php',
'OCP\\Teams\\ITeamResourceProvider' => $baseDir . '/lib/public/Teams/ITeamResourceProvider.php',
'OCP\\Teams\\Team' => $baseDir . '/lib/public/Teams/Team.php',
'OCP\\Teams\\TeamActivityScope' => $baseDir . '/lib/public/Teams/TeamActivityScope.php',
'OCP\\Teams\\TeamFolder' => $baseDir . '/lib/public/Teams/TeamFolder.php',
'OCP\\Teams\\TeamResource' => $baseDir . '/lib/public/Teams/TeamResource.php',
'OCP\\Template' => $baseDir . '/lib/public/Template.php',
Expand Down
2 changes: 2 additions & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,10 +1118,12 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\TaskProcessing\\TaskTypes\\TextToTextSummary' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextSummary.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextTopics' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextTopics.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextTranslate' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextTranslate.php',
'OCP\\Teams\\ITeamActivityResourceProvider' => __DIR__ . '/../../..' . '/lib/public/Teams/ITeamActivityResourceProvider.php',
'OCP\\Teams\\ITeamFolderProvider' => __DIR__ . '/../../..' . '/lib/public/Teams/ITeamFolderProvider.php',
'OCP\\Teams\\ITeamManager' => __DIR__ . '/../../..' . '/lib/public/Teams/ITeamManager.php',
'OCP\\Teams\\ITeamResourceProvider' => __DIR__ . '/../../..' . '/lib/public/Teams/ITeamResourceProvider.php',
'OCP\\Teams\\Team' => __DIR__ . '/../../..' . '/lib/public/Teams/Team.php',
'OCP\\Teams\\TeamActivityScope' => __DIR__ . '/../../..' . '/lib/public/Teams/TeamActivityScope.php',
'OCP\\Teams\\TeamFolder' => __DIR__ . '/../../..' . '/lib/public/Teams/TeamFolder.php',
'OCP\\Teams\\TeamResource' => __DIR__ . '/../../..' . '/lib/public/Teams/TeamResource.php',
'OCP\\Template' => __DIR__ . '/../../..' . '/lib/public/Template.php',
Expand Down
28 changes: 28 additions & 0 deletions lib/public/Teams/ITeamActivityResourceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCP\Teams;

use OCP\AppFramework\Attribute\Implementable;

/**
* An optional Team resource provider capability for Team Activity.
*
* @since 36.0.0
*/
Comment thread
hefftich marked this conversation as resolved.
#[Implementable(since: '36.0.0')]
interface ITeamActivityResourceProvider extends ITeamResourceProvider {
/**
* Resolve Team resources into Activity objects visible to the current user.
*
* @param list<TeamResource> $resources Resources from this provider shared with the Team
* @param string $userId The user the activity scopes are resolved for
* @return list<TeamActivityScope>
* @since 36.0.0
*/
public function getActivityScopes(array $resources, string $userId): array;
}
49 changes: 49 additions & 0 deletions lib/public/Teams/TeamActivityScope.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCP\Teams;

use OCP\AppFramework\Attribute\Consumable;

/**
* A set of Activity objects belonging to Team resources.
*
* @since 36.0.0
*/
Comment thread
hefftich marked this conversation as resolved.
#[Consumable(since: '36.0.0')]
final readonly class TeamActivityScope {
/** @var list<positive-int> */
private array $objectIds;

/**
* @param list<positive-int> $objectIds
* @param non-empty-string $objectType
* @since 36.0.0
*/
public function __construct(
private string $objectType,
array $objectIds,
) {
$this->objectIds = array_values(array_unique($objectIds));
}

/**
* @return non-empty-string
* @since 36.0.0
*/
public function getObjectType(): string {
return $this->objectType;
}

/**
* @return list<positive-int>
* @since 36.0.0
*/
public function getObjectIds(): array {
return $this->objectIds;
}
}
13 changes: 12 additions & 1 deletion lib/public/Teams/TeamFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function __construct(
private int $id,
private string $mountPoint,
private ?int $quota = null,
private ?int $rootFileId = null,
) {
}

Expand Down Expand Up @@ -53,7 +54,16 @@ public function getQuota(): ?int {
}

/**
* @return array{id: int, quota: int|null, mountPoint: string}
* Return the filecache ID of the folder's root, when exposed by the provider.
*
* @since 36.0.0
*/
public function getRootFileId(): ?int {
return $this->rootFileId;
}

/**
* @return array{id: int, quota: int|null, mountPoint: string, rootFileId: int|null}
* @since 35.0.0
*/
#[\Override]
Expand All @@ -62,6 +72,7 @@ public function jsonSerialize(): array {
'id' => $this->id,
'quota' => $this->quota,
'mountPoint' => $this->mountPoint,
'rootFileId' => $this->rootFileId,
];
}
}
68 changes: 68 additions & 0 deletions tests/lib/Teams/TeamActivityScopeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace Test\Teams;

use OCP\AppFramework\Attribute\Consumable;
use OCP\AppFramework\Attribute\Implementable;
use OCP\Teams\ITeamActivityResourceProvider;
use OCP\Teams\TeamActivityScope;
use Test\TestCase;

class TeamActivityScopeTest extends TestCase {
public function testGettersReturnConstructorValues(): void {
$scope = new TeamActivityScope('files', [1, 2, 3]);

$this->assertSame('files', $scope->getObjectType());
$this->assertSame([1, 2, 3], $scope->getObjectIds());
}

public function testDeduplicatesObjectIds(): void {
$scope = new TeamActivityScope('files', [1, 2, 2, 3, 1]);

$this->assertSame([1, 2, 3], $scope->getObjectIds());
}

public function testAllowsEmptyObjectIds(): void {
$scope = new TeamActivityScope('files', []);

$this->assertSame([], $scope->getObjectIds());
}

public function testReturnedObjectIdsDoNotMutateScope(): void {
$scope = new TeamActivityScope('files', [1, 2, 3]);
$objectIds = $scope->getObjectIds();
$objectIds[] = 4;

$this->assertSame([1, 2, 3], $scope->getObjectIds());
}

public function testScopeIsFinalAndReadonly(): void {
$class = new \ReflectionClass(TeamActivityScope::class);

$this->assertTrue($class->isFinal());
$this->assertTrue($class->isReadOnly());
}

public function testScopeIsConsumable(): void {
$class = new \ReflectionClass(TeamActivityScope::class);
$attributes = $class->getAttributes(Consumable::class);

$this->assertCount(1, $attributes);
$this->assertSame('36.0.0', $attributes[0]->newInstance()->getSince());
}

public function testProviderIsImplementable(): void {
$class = new \ReflectionClass(ITeamActivityResourceProvider::class);
$attributes = $class->getAttributes(Implementable::class);

$this->assertCount(1, $attributes);
$this->assertSame('36.0.0', $attributes[0]->newInstance()->getSince());
}
}
12 changes: 10 additions & 2 deletions tests/lib/Teams/TeamFolderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ public function testSerializesFolderIdentity(): void {
$this->assertSame(42, $folder->getId());
$this->assertSame('Engineering', $folder->getMountPoint());
$this->assertNull($folder->getQuota());
$this->assertSame(['id' => 42, 'quota' => null, 'mountPoint' => 'Engineering'], $folder->jsonSerialize());
$this->assertNull($folder->getRootFileId());
$this->assertSame(['id' => 42, 'quota' => null, 'mountPoint' => 'Engineering', 'rootFileId' => null], $folder->jsonSerialize());
}

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

$this->assertSame(1024, $folder->getQuota());
$this->assertSame(['id' => 42, 'quota' => 1024, 'mountPoint' => 'Engineering'], $folder->jsonSerialize());
$this->assertSame(['id' => 42, 'quota' => 1024, 'mountPoint' => 'Engineering', 'rootFileId' => null], $folder->jsonSerialize());
}

public function testSerializesFolderRootFileId(): void {
$folder = new TeamFolder(42, 'Engineering', 1024, 1337);

$this->assertSame(1337, $folder->getRootFileId());
$this->assertSame(['id' => 42, 'quota' => 1024, 'mountPoint' => 'Engineering', 'rootFileId' => 1337], $folder->jsonSerialize());
}
}
Loading