mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Define JMAP FolderModel.myRights
This commit is contained in:
parent
ea55eb13e5
commit
7f40c317d0
3 changed files with 40 additions and 24 deletions
|
|
@ -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({
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue