Skip to content

Commit 4951d16

Browse files
feat(share): make ShareReviewEntry timestamps explicit and add canManage
Replace the time/timestamp string-int duo with a required lastModifiedTimestamp, turn expiration into an expiration timestamp, rename password to hasPassword and model the manage capability as a dedicated flag so the permissions field fits int-mask-of<Constants::PERMISSION_*>. Assisted-by: Claude Code:claude-fable-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent fa57f02 commit 4951d16

2 files changed

Lines changed: 32 additions & 23 deletions

File tree

lib/public/Share/ShareReview/ShareReviewEntry.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
namespace OCP\Share\ShareReview;
1111

1212
use OCP\AppFramework\Attribute\Consumable;
13+
use OCP\Constants;
14+
use OCP\Share\IShare;
1315

1416
/**
1517
* Holds a single app-managed share as exposed to a share-review app through
@@ -25,16 +27,22 @@ final class ShareReviewEntry {
2527
* @param string $object Name or title of the shared object, such as a
2628
* file path or report name.
2729
* @param string $initiator User ID of the initiator.
28-
* @param int $type {@see \OCP\Share\IShare} type of the share.
30+
* @param IShare::TYPE_* $type {@see \OCP\Share\IShare} type of the share.
2931
* @param string $recipient User ID of the owner or the token of a link.
30-
* @param int $permissions Permissions level of the share.
31-
* @param string $time Creation time of the share.
32+
* @param int $lastModifiedTimestamp Unix timestamp of the share's creation
33+
* or last modification, whichever is
34+
* later; used for sorting and for the
35+
* new-since-last-review filter. Pass 0
36+
* if the app tracks neither.
37+
* @param int-mask-of<Constants::PERMISSION_*> $permissions Permissions level of the share.
3238
* @param string $action Optional deletion identifier override. An empty
3339
* string means $id is used.
34-
* @param int|null $timestamp Optional creation Unix timestamp, used for sorting.
35-
* @param bool $password Whether the share is password protected. Never
36-
* the password itself.
37-
* @param string|null $expiration Optional expiration date displayed for the share.
40+
* @param bool $hasPassword Whether the share is password protected. Never
41+
* the password itself.
42+
* @param bool $canManage Whether the recipient can administer the shared
43+
* object and its sharing.
44+
* @param int|null $expirationTimestamp Optional expiration Unix timestamp
45+
* of the share.
3846
* @param string|null $parent Optional identifier of the parent share.
3947
*
4048
* @since 34.0.2
@@ -45,12 +53,12 @@ public function __construct(
4553
public readonly string $initiator,
4654
public readonly int $type,
4755
public readonly string $recipient,
56+
public readonly int $lastModifiedTimestamp,
4857
public readonly int $permissions = 1,
49-
public readonly string $time = '1970-01-01 01:00:00',
5058
public readonly string $action = '',
51-
public readonly ?int $timestamp = null,
52-
public readonly bool $password = false,
53-
public readonly ?string $expiration = null,
59+
public readonly bool $hasPassword = false,
60+
public readonly bool $canManage = false,
61+
public readonly ?int $expirationTimestamp = null,
5462
public readonly ?string $parent = null,
5563
) {
5664
}

tests/lib/Share20/ShareReview/ShareReviewEntryTest.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ public function testHoldsAllFields(): void {
2222
initiator: 'alice',
2323
type: IShare::TYPE_USER,
2424
recipient: 'bob',
25+
lastModifiedTimestamp: 1783764000,
2526
permissions: 31,
26-
time: '2026-07-07 12:00:00',
2727
action: 'board-share-42',
28-
timestamp: 1783764000,
29-
password: true,
30-
expiration: '2026-08-01',
28+
hasPassword: true,
29+
canManage: true,
30+
expirationTimestamp: 1785837600,
3131
parent: '23',
3232
);
3333

@@ -36,12 +36,12 @@ public function testHoldsAllFields(): void {
3636
$this->assertSame('alice', $entry->initiator);
3737
$this->assertSame(IShare::TYPE_USER, $entry->type);
3838
$this->assertSame('bob', $entry->recipient);
39+
$this->assertSame(1783764000, $entry->lastModifiedTimestamp);
3940
$this->assertSame(31, $entry->permissions);
40-
$this->assertSame('2026-07-07 12:00:00', $entry->time);
4141
$this->assertSame('board-share-42', $entry->action);
42-
$this->assertSame(1783764000, $entry->timestamp);
43-
$this->assertTrue($entry->password);
44-
$this->assertSame('2026-08-01', $entry->expiration);
42+
$this->assertTrue($entry->hasPassword);
43+
$this->assertTrue($entry->canManage);
44+
$this->assertSame(1785837600, $entry->expirationTimestamp);
4545
$this->assertSame('23', $entry->parent);
4646
}
4747

@@ -52,14 +52,15 @@ public function testDefaults(): void {
5252
initiator: 'alice',
5353
type: IShare::TYPE_LINK,
5454
recipient: 'sToKeN',
55+
lastModifiedTimestamp: 0,
5556
);
5657

58+
$this->assertSame(0, $entry->lastModifiedTimestamp);
5759
$this->assertSame(1, $entry->permissions);
58-
$this->assertSame('1970-01-01 01:00:00', $entry->time);
5960
$this->assertSame('', $entry->action);
60-
$this->assertNull($entry->timestamp);
61-
$this->assertFalse($entry->password);
62-
$this->assertNull($entry->expiration);
61+
$this->assertFalse($entry->hasPassword);
62+
$this->assertFalse($entry->canManage);
63+
$this->assertNull($entry->expirationTimestamp);
6364
$this->assertNull($entry->parent);
6465
}
6566
}

0 commit comments

Comments
 (0)