Skip to content

Commit e6d4605

Browse files
authored
fixed ocs function for Group Folders app routes (#279)
Fixes #277 . Changes proposed in this pull request: * we use `request.headers["Accept"] = "application/json"` in addition of appending `format=json` to the query url(look below why). * changed ocs_regexp to `r"/ocs/v[12]\.php/|/apps/groupfolders/"` until groupfolder app will fix it. Signed-off-by: Alexander Piskun <[email protected]>
1 parent e56e324 commit e6d4605

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ All notable changes to this project will be documented in this file.
66

77
### Fixed
88

9-
- NextcloudApp: `get_computation_device` function now correctly returns result in upper_case.
9+
- Corrected behaviour of `ocs` function for `Group Folders` app routes(they are not fully OCS API). #279
10+
- NextcloudApp: `get_computation_device` function now correctly returns result in upper_case. #278
1011

1112
## [0.15.0 - 2024-07-19]
1213

nc_py_api/_session.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def __init__(self, **kwargs):
150150
self.init_adapter()
151151
self.init_adapter_dav()
152152
self.response_headers = Headers()
153-
self._ocs_regexp = re.compile(r"/ocs/v[12]\.php/")
153+
self._ocs_regexp = re.compile(r"/ocs/v[12]\.php/|/apps/groupfolders/")
154154

155155
def init_adapter(self, restart=False) -> None:
156156
if getattr(self, "adapter", None) is None or restart:
@@ -289,6 +289,7 @@ def _request_event_ocs(self, request: Request) -> None:
289289
str_url = str(request.url)
290290
if re.search(self._ocs_regexp, str_url) is not None: # this is OCS call
291291
request.url = request.url.copy_merge_params({"format": "json"})
292+
request.headers["Accept"] = "application/json"
292293

293294
def _response_event(self, response: Response) -> None:
294295
str_url = str(response.request.url)
@@ -412,6 +413,7 @@ async def _request_event_ocs(self, request: Request) -> None:
412413
str_url = str(request.url)
413414
if re.search(self._ocs_regexp, str_url) is not None: # this is OCS call
414415
request.url = request.url.copy_merge_params({"format": "json"})
416+
request.headers["Accept"] = "application/json"
415417

416418
async def _response_event(self, response: Response) -> None:
417419
str_url = str(response.request.url)

0 commit comments

Comments
 (0)