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
21 changes: 20 additions & 1 deletion lib/TeamSpace/TeamSpaceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@

use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Teams\ITeamActivityResourceProvider;
use OCP\Teams\ITeamFolderProvider;
use OCP\Teams\Team;
use OCP\Teams\TeamActivityScope;
use OCP\Teams\TeamFolder;
use OCP\Teams\TeamResource;

class TeamSpaceProvider implements ITeamFolderProvider {
class TeamSpaceProvider implements ITeamFolderProvider, ITeamActivityResourceProvider {

Check failure on line 21 in lib/TeamSpace/TeamSpaceProvider.php

View workflow job for this annotation

GitHub Actions / static-phpstan-analysis

Class OCA\GroupFolders\TeamSpace\TeamSpaceProvider implements unknown interface OCP\Teams\ITeamActivityResourceProvider.
public function __construct(
private readonly TeamSpaceService $service,
private readonly IL10N $l10n,
Expand Down Expand Up @@ -120,6 +122,23 @@
}, $this->service->getGroupFoldersForCircle($teamId));
}

/**
* @param list<TeamResource> $resources
* @return list<TeamActivityScope>
*/
#[\Override]

Check failure on line 129 in lib/TeamSpace/TeamSpaceProvider.php

View workflow job for this annotation

GitHub Actions / static-phpstan-analysis

Method OCA\GroupFolders\TeamSpace\TeamSpaceProvider::getActivityScopes() has #[\Override] attribute but does not override any method.
public function getActivityScopes(array $resources, string $userId): array {

Check failure on line 130 in lib/TeamSpace/TeamSpaceProvider.php

View workflow job for this annotation

GitHub Actions / static-phpstan-analysis

Method OCA\GroupFolders\TeamSpace\TeamSpaceProvider::getActivityScopes() has invalid return type OCP\Teams\TeamActivityScope.
$folderIds = [];
foreach ($resources as $resource) {
if (ctype_digit($resource->getId())) {
$folderIds[] = (int)$resource->getId();
}
}

$rootFileIds = $this->service->getRootFileIds(array_values(array_unique($folderIds)));
return $rootFileIds === [] ? [] : [new TeamActivityScope('files', $rootFileIds)];

Check failure on line 139 in lib/TeamSpace/TeamSpaceProvider.php

View workflow job for this annotation

GitHub Actions / static-phpstan-analysis

Instantiated class OCP\Teams\TeamActivityScope not found.
}

#[\Override]
public function isSharedWithTeam(string $teamId, string $resourceId): bool {
foreach ($this->service->getGroupFoldersForCircle($teamId) as $folder) {
Expand Down
18 changes: 17 additions & 1 deletion lib/TeamSpace/TeamSpaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@

$this->createAppDirectory($folderId);

return new TeamFolder($folder->id, $folder->mountPoint, $folder->quota);
return new TeamFolder($folder->id, $folder->mountPoint, $folder->quota, $folder->rootId);

Check failure on line 236 in lib/TeamSpace/TeamSpaceService.php

View workflow job for this annotation

GitHub Actions / static-phpstan-analysis

Class OCP\Teams\TeamFolder constructor invoked with 4 parameters, 2-3 required.
}

/**
Expand Down Expand Up @@ -275,6 +275,22 @@
);
}

/**
* @param list<int> $folderIds
* @return list<int>
*/
public function getRootFileIds(array $folderIds): array {
$rootFileIds = [];
foreach ($folderIds as $folderId) {
$folder = $this->folderManager->getFolder($folderId);
if ($folder !== null && $folder->rootId > 0) {
$rootFileIds[] = $folder->rootId;
}
}

return array_values(array_unique($rootFileIds));
}

/**
* Return existing folders directly available to a team that have not been
* made an exclusive team folder for another team.
Expand Down
20 changes: 20 additions & 0 deletions tests/TeamSpace/TeamSpaceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
use OCA\GroupFolders\TeamSpace\TeamSpaceService;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Teams\TeamActivityScope;
use OCP\Teams\TeamFolder;
use OCP\Teams\TeamResource;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;

Expand Down Expand Up @@ -65,6 +67,24 @@
$this->assertSame('https://cloud.example/apps/files/?dir=/Shared%20projects', $resources[1]->getUrl());
}

public function testGetActivityScopesReturnsGroupFolderRoots(): void {
$resources = [
new TeamResource($this->provider, '42', 'Engineering', 'https://cloud.example/engineering'),
new TeamResource($this->provider, '43', 'Shared projects', 'https://cloud.example/projects'),
];
$this->service->expects($this->once())
->method('getRootFileIds')
->with([42, 43])
->willReturn([420, 430]);

$scopes = $this->provider->getActivityScopes($resources, 'alice');

$this->assertCount(1, $scopes);
$this->assertInstanceOf(TeamActivityScope::class, $scopes[0]);

Check failure on line 83 in tests/TeamSpace/TeamSpaceProviderTest.php

View workflow job for this annotation

GitHub Actions / static-phpstan-analysis

Class OCP\Teams\TeamActivityScope not found.
$this->assertSame('files', $scopes[0]->getObjectType());

Check failure on line 84 in tests/TeamSpace/TeamSpaceProviderTest.php

View workflow job for this annotation

GitHub Actions / static-phpstan-analysis

Call to method getObjectType() on an unknown class OCP\Teams\TeamActivityScope.
$this->assertSame([420, 430], $scopes[0]->getObjectIds());

Check failure on line 85 in tests/TeamSpace/TeamSpaceProviderTest.php

View workflow job for this annotation

GitHub Actions / static-phpstan-analysis

Call to method getObjectIds() on an unknown class OCP\Teams\TeamActivityScope.
}

public function testGetLinkableTeamFoldersDelegatesToService(): void {
$folders = [new TeamFolder(42, 'Engineering')];
$this->service->expects($this->once())
Expand Down
Loading