Define JMAP FolderModel.myRights

This commit is contained in:
the-djmaze 2024-02-11 17:00:09 +01:00
parent ea55eb13e5
commit 7f40c317d0
3 changed files with 40 additions and 24 deletions

View file

@ -366,20 +366,19 @@ export class FolderModel extends AbstractModel {
}) })
.extend({ notify: 'always' }); .extend({ notify: 'always' });
*/ */
/*
https://www.rfc-editor.org/rfc/rfc8621.html#section-2 // https://www.rfc-editor.org/rfc/rfc8621.html#section-2
"myRights": { this.myRights = {
"mayAddItems": true, 'mayAddItems': true,
"mayRename": false, 'mayCreateChild': true,
"maySubmit": true, 'mayDelete': true,
"mayDelete": false, 'mayReadItems': true,
"maySetKeywords": true, 'mayRemoveItems': true,
"mayRemoveItems": true, 'mayRename': true,
"mayCreateChild": true, 'maySetKeywords': true,
"maySetSeen": true, 'maySetSeen': true,
"mayReadItems": true 'maySubmit': true
}, };
*/
this.addComputables({ this.addComputables({

View file

@ -148,6 +148,7 @@ class Folder implements \JsonSerializable
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
public function jsonSerialize() public function jsonSerialize()
{ {
$selectable = $this->Selectable();
$result = array( $result = array(
'@Object' => 'Object/Folder', '@Object' => 'Object/Folder',
'name' => $this->Name(), 'name' => $this->Name(),
@ -163,16 +164,17 @@ class Folder implements \JsonSerializable
'size' => $this->SIZE, 'size' => $this->SIZE,
'role' => $this->Role(), 'role' => $this->Role(),
'myRights' => [ 'rights' => $this->myRights,
'mayReadItems' => !$this->myRights || ($this->myRights->hasRight('l') && $this->myRights->hasRight('r')), 'myRights' => $this->myRights ? $this->myRights->JMAP() : [
'mayAddItems' => !$this->myRights || $this->myRights->hasRight('i'), 'mayReadItems' => $selectable,
'mayRemoveItems' => !$this->myRights || ($this->myRights->hasRight('t') && $this->myRights->hasRight('e')), 'mayAddItems' => $selectable,
'maySetSeen' => !$this->myRights || $this->myRights->hasRight('s'), 'mayRemoveItems' => $selectable,
'maySetKeywords' => !$this->myRights || $this->myRights->hasRight('w'), 'maySetSeen' => $selectable,
'mayCreateChild' => !$this->myRights || $this->myRights->hasRight('k'), 'maySetKeywords' => $selectable,
'mayRename' => !$this->myRights || $this->myRights->hasRight('x'), 'mayCreateChild' => $selectable,
'mayDelete' => !$this->myRights || $this->myRights->hasRight('x'), 'mayRename' => $selectable,
'maySubmit' => !$this->myRights || $this->myRights->hasRight('p') 'mayDelete' => $selectable,
'maySubmit' => $selectable
] ]
); );
if ($this->etag) { if ($this->etag) {

View file

@ -46,4 +46,19 @@ class ACL implements \JsonSerializable
return $this->rights; return $this->rights;
} }
public function JMAP() : array
{
return [
'mayReadItems' => ($this->hasRight('l') && $this->hasRight('r')),
'mayAddItems' => $this->hasRight('i'),
'mayRemoveItems' => ($this->hasRight('t') && $this->hasRight('e')),
'maySetSeen' => $this->hasRight('s'),
'maySetKeywords' => $this->hasRight('w'),
'mayCreateChild' => $this->hasRight('k'),
'mayRename' => $this->hasRight('x'),
'mayDelete' => $this->hasRight('x'),
'maySubmit' => $this->hasRight('p')
];
}
} }