Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/nextcloud/api_wrappers/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ class Share(base.OCSv2ApiWrapper):
""" Share API wrapper """
API_URL = "/ocs/v2.php/apps/files_sharing/api/v1"
LOCAL = "shares"
SHARE_WITH_ENABLED_SHARE_TYPES = [
ShareType.USER,
ShareType.GROUP,
ShareType.EMAIL,
ShareType.CIRCLE,
ShareType.FEDERATED_CLOUD_SHARE,
ShareType.TALK_CONVERSATION
]

def get_local_url(self, additional_url=""):
if additional_url:
Expand All @@ -34,7 +42,7 @@ def validate_share_parameters(path, share_type, share_with):
if (
path is None or not isinstance(share_type, int) or (
share_with is None and
share_type in [ShareType.GROUP, ShareType.USER, ShareType.FEDERATED_CLOUD_SHARE]
share_type in Share.SHARE_WITH_ENABLED_SHARE_TYPES
)
):
return False
Expand Down Expand Up @@ -106,7 +114,8 @@ def create_share(
public_upload = "true"

data = {"path": path, "shareType": share_type}
if share_type in [ShareType.GROUP, ShareType.USER, ShareType.FEDERATED_CLOUD_SHARE]:

if share_type in self.SHARE_WITH_ENABLED_SHARE_TYPES:
data["shareWith"] = share_with
if public_upload:
data["publicUpload"] = public_upload
Expand Down
3 changes: 3 additions & 0 deletions src/nextcloud/codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ class ShareType:
USER = 0
GROUP = 1
PUBLIC_LINK = 3
EMAIL = 4
FEDERATED_CLOUD_SHARE = 6
CIRCLE = 7
TALK_CONVERSATION = 10


class Permission:
Expand Down