Skip to content

Commit 8748dd8

Browse files
committed
fixed CI for NC30, last adjustments for webhooks
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
1 parent 35ffed2 commit 8748dd8

File tree

6 files changed

+34
-7
lines changed

6 files changed

+34
-7
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [0.14.0 - 2024-07-0X]
5+
## [0.15.0 - 2024-07-19]
6+
7+
### Added
8+
9+
- Initial Webhooks API support for the upcoming Nextcloud 30. #272
10+
11+
### Changed
12+
13+
- NextcloudApp: `fetch_models_task` function now saves paths to downloaded models. #274 Thanks to @kyteinsky
14+
15+
## [0.14.0 - 2024-07-09]
616

717
### Added
818

docs/reference/Webhooks.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. py:currentmodule:: nc_py_api.webhooks
2+
3+
Webhooks API
4+
============
5+
6+
.. autoclass:: nc_py_api.webhooks.WebhookInfo
7+
:members:
8+
9+
.. autoclass:: nc_py_api.webhooks._WebhooksAPI
10+
:members:

docs/reference/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ Reference
1717
Notes
1818
Session
1919
LoginFlowV2
20+
Webhooks

nc_py_api/webhooks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def app_id(self) -> str:
2626
@property
2727
def user_id(self) -> str:
2828
"""`UserID` if webhook was registered in user context."""
29-
return self._raw_data["userId"]
29+
return self._raw_data["userId"] if self._raw_data["userId"] else ""
3030

3131
@property
3232
def http_method(self) -> str:
@@ -45,7 +45,7 @@ def event(self) -> str:
4545

4646
@property
4747
def event_filter(self):
48-
"""Currently unknown."""
48+
"""Mongo filter to apply to the serialized data to decide if firing."""
4949
return self._raw_data["eventFilter"]
5050

5151
@property
@@ -138,7 +138,7 @@ def update(
138138
return WebhookInfo(self._session.ocs("POST", f"{self._ep_base}/{webhook_id}", json=params))
139139

140140
def unregister(self, webhook_id: int) -> bool:
141-
return self._session.ocs("DELETE", f"{self._session.ae_url}/{webhook_id}")
141+
return self._session.ocs("DELETE", f"{self._ep_base}/{webhook_id}")
142142

143143

144144
class _AsyncWebhooksAPI:
@@ -207,4 +207,4 @@ async def update(
207207
return WebhookInfo(await self._session.ocs("POST", f"{self._ep_base}/{webhook_id}", json=params))
208208

209209
async def unregister(self, webhook_id: int) -> bool:
210-
return await self._session.ocs("DELETE", f"{self._session.ae_url}/{webhook_id}")
210+
return await self._session.ocs("DELETE", f"{self._ep_base}/{webhook_id}")

tests/actual_tests/files_sharing_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,12 @@ async def test_share_fields_async(anc_any):
8383
def test_create_permissions(nc_any):
8484
new_share = nc_any.files.sharing.create("test_empty_dir", ShareType.TYPE_LINK, FilePermissions.PERMISSION_CREATE)
8585
nc_any.files.sharing.delete(new_share)
86+
# starting from Nextcloud 30 permissions are: FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
87+
# https://github.com/nextcloud/server/commit/0bde47a39256dfad3baa8d3ffa275ac3d113a9d5#diff-dbbe017dd357504abc442a6f1d0305166520ebf80353f42814b3f879a3e241bc
8688
assert (
8789
new_share.permissions
8890
== FilePermissions.PERMISSION_READ | FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
91+
or new_share.permissions == FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
8992
)
9093
new_share = nc_any.files.sharing.create("test_empty_dir", ShareType.TYPE_LINK, FilePermissions.PERMISSION_DELETE)
9194
nc_any.files.sharing.delete(new_share)
@@ -107,9 +110,12 @@ async def test_create_permissions_async(anc_any):
107110
"test_empty_dir", ShareType.TYPE_LINK, FilePermissions.PERMISSION_CREATE
108111
)
109112
await anc_any.files.sharing.delete(new_share)
113+
# starting from Nextcloud 30 permissions are: FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
114+
# https://github.com/nextcloud/server/commit/0bde47a39256dfad3baa8d3ffa275ac3d113a9d5#diff-dbbe017dd357504abc442a6f1d0305166520ebf80353f42814b3f879a3e241bc
110115
assert (
111116
new_share.permissions
112117
== FilePermissions.PERMISSION_READ | FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
118+
or new_share.permissions == FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
113119
)
114120
new_share = await anc_any.files.sharing.create(
115121
"test_empty_dir", ShareType.TYPE_LINK, FilePermissions.PERMISSION_DELETE

tests/gfixture_set_env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
if not environ.get("CI", False): # For local tests
44
environ["NC_AUTH_USER"] = "admin"
55
environ["NC_AUTH_PASS"] = "admin" # "MrtGY-KfY24-iiDyg-cr4n4-GLsNZ"
6-
environ["NEXTCLOUD_URL"] = environ.get("NEXTCLOUD_URL", "http://stable27.local")
7-
# environ["NEXTCLOUD_URL"] = environ.get("NEXTCLOUD_URL", "http://stable28.local")
6+
environ["NEXTCLOUD_URL"] = environ.get("NEXTCLOUD_URL", "http://stable29.local")
7+
# environ["NEXTCLOUD_URL"] = environ.get("NEXTCLOUD_URL", "http://stable30.local")
88
# environ["NEXTCLOUD_URL"] = environ.get("NEXTCLOUD_URL", "http://nextcloud.local")
99
environ["APP_ID"] = "nc_py_api"
1010
environ["APP_VERSION"] = "1.0.0"

0 commit comments

Comments
 (0)