Skip to content

Commit bc02751

Browse files
authored
update for UiActionFileInfo (#90)
nextcloud/app_api/pull/45 Signed-off-by: Alexander Piskun <[email protected]>
1 parent 858ab3e commit bc02751

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

examples/as_app/to_gif/appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</docker-install>
2727
<scopes>
2828
<required>
29-
<value>2</value>
29+
<value>10</value>
3030
</required>
3131
<optional>
3232
<value>32</value>

nc_py_api/ex_app/ui/files.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Nextcloud API for working with drop-down file's menu."""
22
import os
3+
import typing
34
from datetime import datetime, timezone
45

56
from pydantic import BaseModel
@@ -35,8 +36,10 @@ class UiActionFileInfo(BaseModel):
3536
"""Last modified time"""
3637
userId: str
3738
"""The ID of the user performing the action."""
38-
shared: str
39-
"""**true** or **false**"""
39+
shareOwner: typing.Optional[str]
40+
"""If the object is shared, this is a display name of the share owner."""
41+
shareOwnerId: typing.Optional[str]
42+
"""If the object is shared, this is the owner ID of the share."""
4043

4144
def to_fs_node(self) -> FsNode:
4245
"""Returns created ``FsNode`` from the file info given.
@@ -50,7 +53,7 @@ def to_fs_node(self) -> FsNode:
5053
user_path += "/"
5154
full_path = os.path.join(f"files/{self.userId}", user_path.lstrip("/"))
5255

53-
permissions = "S" if self.shared.lower() == "true" else ""
56+
permissions = "S" if self.shareOwnerId else ""
5457
if self.permissions & FilePermissions.PERMISSION_SHARE:
5558
permissions += "R"
5659
if self.permissions & FilePermissions.PERMISSION_READ:

tests/ui_files_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def ui_action_check(directory: str, fs_object: FsNode):
104104
favorite=str(fs_object.info.favorite),
105105
permissions=permissions,
106106
userId=fs_object.user,
107-
shared="true" if fs_object.is_shared else "false",
107+
shareOwner="some_user" if fs_object.is_shared else None,
108+
shareOwnerId="some_user_id" if fs_object.is_shared else None,
108109
)
109110
fs_node = file_info.to_fs_node()
110111
assert isinstance(fs_node, FsNode)

0 commit comments

Comments
 (0)