Skip to content

Commit 5feab5e

Browse files
Fin-ctomek2k1
authored andcommitted
feat(Teams): Add quota management to TeamFolder and ITeamFolderProvider
Signed-off-by: Fin Clausen <Fin.Clausen@dataport.de> Co-authored-by: Tomasz Trillo <tomasz.trillo@dataport.de>
1 parent 7f7fdcb commit 5feab5e

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

lib/public/Teams/ITeamFolderProvider.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ public function getTeamFolder(string $teamId): ?TeamFolder;
3939
*/
4040
public function createTeamFolder(Team $team, int $quota = 0): TeamFolder;
4141

42+
/**
43+
* Update the storage quota of the team folder.
44+
*
45+
* @param string $teamId The team single id.
46+
* @param int $quota Quota in bytes; zero means unlimited.
47+
* @return TeamFolder The updated folder.
48+
* @since 35.0.0
49+
*/
50+
public function updateTeamFolderQuota(string $teamId, int $quota): TeamFolder;
51+
4252
/**
4353
* Remove the exclusive relationship but retain the folder and its contents.
4454
*

lib/public/Teams/TeamFolder.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class TeamFolder implements \JsonSerializable {
2424
public function __construct(
2525
private int $id,
2626
private string $mountPoint,
27+
private ?int $quota = null,
2728
) {
2829
}
2930

@@ -42,13 +43,24 @@ public function getMountPoint(): string {
4243
}
4344

4445
/**
45-
* @return array{id: int, mountPoint: string}
46+
* The storage quota in bytes, zero for unlimited, or null if the active
47+
* provider does not expose a quota for this folder.
48+
*
49+
* @since 35.0.0
50+
*/
51+
public function getQuota(): ?int {
52+
return $this->quota;
53+
}
54+
55+
/**
56+
* @return array{id: int, quota: int|null, mountPoint: string}
4657
* @since 35.0.0
4758
*/
4859
#[\Override]
4960
public function jsonSerialize(): array {
5061
return [
5162
'id' => $this->id,
63+
'quota' => $this->quota,
5264
'mountPoint' => $this->mountPoint,
5365
];
5466
}

tests/lib/Teams/TeamFolderTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ public function testSerializesFolderIdentity(): void {
1818

1919
$this->assertSame(42, $folder->getId());
2020
$this->assertSame('Engineering', $folder->getMountPoint());
21-
$this->assertSame(['id' => 42, 'mountPoint' => 'Engineering'], $folder->jsonSerialize());
21+
$this->assertNull($folder->getQuota());
22+
$this->assertSame(['id' => 42, 'quota' => null, 'mountPoint' => 'Engineering'], $folder->jsonSerialize());
23+
}
24+
25+
public function testSerializesFolderQuota(): void {
26+
$folder = new TeamFolder(42, 'Engineering', 1024);
27+
28+
$this->assertSame(1024, $folder->getQuota());
29+
$this->assertSame(['id' => 42, 'quota' => 1024, 'mountPoint' => 'Engineering'], $folder->jsonSerialize());
2230
}
2331
}

0 commit comments

Comments
 (0)