Skip to content

Commit

Permalink
NextCloudRichObject: Initialization with required props and support s… (
Browse files Browse the repository at this point in the history
#17)

* NextCloudRichObject: Initialization with required props and support sending all other props

Signed-off-by: José Luis Di Biase <josx@interorganic.com.ar>

* NextCloudRichObject File type: check for allowed props

Signed-off-by: José Luis Di Biase <josx@interorganic.com.ar>

---------

Signed-off-by: José Luis Di Biase <josx@interorganic.com.ar>
  • Loading branch information
josx authored Aug 10, 2023
1 parent 08f944e commit 05923cc
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions nextcloud_async/api/ocs/talk/rich_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,28 +101,27 @@ class File(NextCloudTalkRichObject):

object_type = 'file'
path = ''
link = ''

def __init__(self, name: str, path: str, link: str):
allowed_props = ['size', 'link', 'mimetype', 'preview-available', 'mtime']

def __init__(self, name: str, path: str, **kwargs):
"""Set file object metadata."""
data = {

if not all(key in self.allowed_props for key in kwargs):
raise ValueError(f'Supported properties {self.allowed_props}')

init = {
'id': name,
'name': name,
'path': path,
'link': link,
}
data = { **init, **kwargs }
super().__init__(**data)

@property
def metadata(self):
"""Return object metadata."""
return {
'id': self.id,
'name': self.name,
'path': self.path,
'link': self.link,
}

return self.__dict__

class Form(NextCloudTalkRichObject):
"""Form."""
Expand Down

0 comments on commit 05923cc

Please sign in to comment.