Skip to content

Commit

Permalink
update for UiActionFileInfo (#90)
Browse files Browse the repository at this point in the history
nextcloud/app_api/pull/45

Signed-off-by: Alexander Piskun <[email protected]>
  • Loading branch information
bigcat88 authored Aug 17, 2023
1 parent 858ab3e commit bc02751
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/as_app/to_gif/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</docker-install>
<scopes>
<required>
<value>2</value>
<value>10</value>
</required>
<optional>
<value>32</value>
Expand Down
9 changes: 6 additions & 3 deletions nc_py_api/ex_app/ui/files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Nextcloud API for working with drop-down file's menu."""
import os
import typing
from datetime import datetime, timezone

from pydantic import BaseModel
Expand Down Expand Up @@ -35,8 +36,10 @@ class UiActionFileInfo(BaseModel):
"""Last modified time"""
userId: str
"""The ID of the user performing the action."""
shared: str
"""**true** or **false**"""
shareOwner: typing.Optional[str]
"""If the object is shared, this is a display name of the share owner."""
shareOwnerId: typing.Optional[str]
"""If the object is shared, this is the owner ID of the share."""

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

permissions = "S" if self.shared.lower() == "true" else ""
permissions = "S" if self.shareOwnerId else ""
if self.permissions & FilePermissions.PERMISSION_SHARE:
permissions += "R"
if self.permissions & FilePermissions.PERMISSION_READ:
Expand Down
3 changes: 2 additions & 1 deletion tests/ui_files_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def ui_action_check(directory: str, fs_object: FsNode):
favorite=str(fs_object.info.favorite),
permissions=permissions,
userId=fs_object.user,
shared="true" if fs_object.is_shared else "false",
shareOwner="some_user" if fs_object.is_shared else None,
shareOwnerId="some_user_id" if fs_object.is_shared else None,
)
fs_node = file_info.to_fs_node()
assert isinstance(fs_node, FsNode)
Expand Down

0 comments on commit bc02751

Please sign in to comment.