mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-29 07:16:07 +00:00
Define JMAP FolderModel.myRights
This commit is contained in:
@@ -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({
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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')
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user