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' });
*/
/*
https://www.rfc-editor.org/rfc/rfc8621.html#section-2
"myRights": {
"mayAddItems": true,
"mayRename": false,
"maySubmit": true,
"mayDelete": false,
"maySetKeywords": true,
"mayRemoveItems": true,
"mayCreateChild": true,
"maySetSeen": true,
"mayReadItems": true
},
*/
// https://www.rfc-editor.org/rfc/rfc8621.html#section-2
this.myRights = {
'mayAddItems': true,
'mayCreateChild': true,
'mayDelete': true,
'mayReadItems': true,
'mayRemoveItems': true,
'mayRename': true,
'maySetKeywords': true,
'maySetSeen': true,
'maySubmit': true
};
this.addComputables({

View File

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

View File

@@ -46,4 +46,19 @@ class ACL implements \JsonSerializable
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')
];
}
}