Skip to content

Commit 39aa8db

Browse files
authoredOct 9, 2024··
added "webhooks.unregister_all" (#309)
Mainly needed for ExApps, but can also be used in some scripts with admin rights. --------- Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
1 parent 0750270 commit 39aa8db

File tree

5 files changed

+39
-53
lines changed

5 files changed

+39
-53
lines changed
 

‎.github/workflows/analysis-coverage.yml

+11-51
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ jobs:
439439
strategy:
440440
fail-fast: false
441441
matrix:
442-
nextcloud: [ 'stable28', 'stable29', 'master' ]
442+
nextcloud: [ 'stable28', 'stable29', 'stable30' ]
443443
timeout-minutes: 60
444444

445445
services:
@@ -483,15 +483,13 @@ jobs:
483483

484484
- name: Checkout Notes
485485
uses: actions/checkout@v4
486-
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
487486
with:
488487
repository: nextcloud/notes
489488
ref: "main"
490489
path: apps/notes
491490

492491
- name: Checkout Files Locking
493492
uses: actions/checkout@v4
494-
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
495493
with:
496494
repository: nextcloud/files_lock
497495
ref: ${{ matrix.nextcloud }}
@@ -511,11 +509,9 @@ jobs:
511509
PHP_CLI_SERVER_WORKERS=2 php -S localhost:8080 &
512510
513511
- name: Enable Files Locking
514-
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
515512
run: ./occ app:enable files_lock
516513

517514
- name: Enable Notes
518-
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
519515
run: ./occ app:enable notes
520516

521517
- name: Checkout NcPyApi
@@ -528,19 +524,20 @@ jobs:
528524
run: python3 -m pip -v install ".[dev]"
529525

530526
- name: Checkout AppAPI
531-
if: ${{ matrix.nextcloud != 'master' }}
527+
if: ${{ matrix.nextcloud != 'stable30' }}
532528
uses: actions/checkout@v4
533529
with:
534530
path: apps/app_api
535531
repository: nextcloud/app_api
536532
ref: stable29
537533

538534
- name: Checkout AppAPI
539-
if: ${{ matrix.nextcloud == 'master' }}
535+
if: ${{ matrix.nextcloud == 'stable30' }}
540536
uses: actions/checkout@v4
541537
with:
542538
path: apps/app_api
543539
repository: nextcloud/app_api
540+
ref: stable30
544541

545542
- name: Install AppAPI
546543
run: |
@@ -555,20 +552,12 @@ jobs:
555552
kill -15 $(cat /tmp/_install.pid)
556553
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
557554
558-
- name: Talk Branch Main
559-
if: ${{ startsWith(matrix.nextcloud, 'master') }}
560-
run: echo "TALK_BRANCH_NAME=main" >> $GITHUB_ENV
561-
562-
- name: Talk Branch Other
563-
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
564-
run: echo "TALK_BRANCH_NAME=${{ matrix.nextcloud }}" >> $GITHUB_ENV
565-
566555
- name: Checkout Talk
567556
uses: actions/checkout@v4
568557
with:
569558
path: apps/spreed
570559
repository: nextcloud/spreed
571-
ref: ${{ env.TALK_BRANCH_NAME }}
560+
ref: ${{ matrix.nextcloud }}
572561

573562
- name: Install Talk
574563
working-directory: apps/spreed
@@ -627,7 +616,7 @@ jobs:
627616
strategy:
628617
fail-fast: false
629618
matrix:
630-
nextcloud: [ 'stable28', 'stable29', 'master' ]
619+
nextcloud: [ 'stable28', 'stable29', 'stable30' ]
631620
env:
632621
NC_dbname: nextcloud_abz
633622
DATABASE_PGSQL: 1
@@ -704,19 +693,20 @@ jobs:
704693
run: python3 -m pip -v install ".[dev]"
705694

706695
- name: Checkout AppAPI
707-
if: ${{ matrix.nextcloud != 'master' }}
696+
if: ${{ matrix.nextcloud != 'stable30' }}
708697
uses: actions/checkout@v4
709698
with:
710699
path: apps/app_api
711700
repository: nextcloud/app_api
712701
ref: stable29
713702

714703
- name: Checkout AppAPI
715-
if: ${{ matrix.nextcloud == 'master' }}
704+
if: ${{ matrix.nextcloud == 'stable30' }}
716705
uses: actions/checkout@v4
717706
with:
718707
path: apps/app_api
719708
repository: nextcloud/app_api
709+
ref: stable30
720710

721711
- name: Install AppAPI
722712
run: |
@@ -731,20 +721,12 @@ jobs:
731721
kill -15 $(cat /tmp/_install.pid)
732722
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
733723
734-
- name: Talk Branch Main
735-
if: ${{ startsWith(matrix.nextcloud, 'master') }}
736-
run: echo "TALK_BRANCH_NAME=main" >> $GITHUB_ENV
737-
738-
- name: Talk Branch Other
739-
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
740-
run: echo "TALK_BRANCH_NAME=${{ matrix.nextcloud }}" >> $GITHUB_ENV
741-
742724
- name: Checkout Talk
743725
uses: actions/checkout@v4
744726
with:
745727
path: apps/spreed
746728
repository: nextcloud/spreed
747-
ref: ${{ env.TALK_BRANCH_NAME }}
729+
ref: ${{ matrix.nextcloud }}
748730

749731
- name: Install Talk
750732
working-directory: apps/spreed
@@ -808,7 +790,7 @@ jobs:
808790
strategy:
809791
fail-fast: false
810792
matrix:
811-
nextcloud: [ 'stable27', 'stable28', 'stable29', 'master' ]
793+
nextcloud: [ 'stable27', 'stable28', 'stable29', 'stable30', 'master' ]
812794
env:
813795
NEXTCLOUD_URL: "http://localhost:8080/index.php"
814796
timeout-minutes: 60
@@ -884,28 +866,6 @@ jobs:
884866
working-directory: nc_py_api
885867
run: python3 -m pip -v install . pytest pytest-asyncio coverage pillow
886868

887-
- name: Talk Branch Main
888-
if: ${{ startsWith(matrix.nextcloud, 'master') }}
889-
run: echo "TALK_BRANCH_NAME=main" >> $GITHUB_ENV
890-
891-
- name: Talk Branch Other
892-
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
893-
run: echo "TALK_BRANCH_NAME=${{ matrix.nextcloud }}" >> $GITHUB_ENV
894-
895-
- name: Checkout Talk
896-
uses: actions/checkout@v4
897-
with:
898-
path: apps/spreed
899-
repository: nextcloud/spreed
900-
ref: ${{ env.TALK_BRANCH_NAME }}
901-
902-
- name: Install Talk
903-
working-directory: apps/spreed
904-
run: make dev-setup
905-
906-
- name: Enable Talk
907-
run: php occ app:enable spreed
908-
909869
- name: Generate coverage report
910870
working-directory: nc_py_api
911871
run: coverage run -m pytest && coverage xml -o coverage_sqlite_${{ matrix.nextcloud }}_client.xml

‎AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ answer newbie questions, and generally made NC-Py-API that much better:
66
Alexander Piskun <bigcat88@icloud.com>
77
CooperGerman <https://github.com/CooperGerman>
88
Tobias Tschech <Tobias@tschech-online.de>
9+
Scott Williams <scottwilliams@ucsb.edu>
910
<Please alphabetize new entries>
1011

1112
A big THANK YOU goes to:

‎CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

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

5+
## [0.18.0 - 2024-10-09]
6+
7+
### Added
8+
9+
- New `webhooks.unregister_all` method. #309
10+
11+
### Fixed
12+
13+
- Files: `user` and `user_path` properties in `FSNode` when Nextcloud located in in sub-path. #297 Thanks to @vwbusguy
14+
- `files.download_directory_as_zip` method now supports upcoming Nextcloud 31. #304
15+
516
## [0.17.1 - 2024-09-06]
617

718
### Added

‎nc_py_api/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Version of nc_py_api."""
22

3-
__version__ = "0.17.1"
3+
__version__ = "0.18.0.dev0"

‎nc_py_api/webhooks.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import dataclasses
44

55
from ._misc import clear_from_params_empty # , require_capabilities
6-
from ._session import AsyncNcSessionBasic, NcSessionBasic
6+
from ._session import AppConfig, AsyncNcSessionBasic, NcSessionBasic
77

88

99
@dataclasses.dataclass
@@ -140,6 +140,13 @@ def update(
140140
def unregister(self, webhook_id: int) -> bool:
141141
return self._session.ocs("DELETE", f"{self._ep_base}/{webhook_id}")
142142

143+
def unregister_all(self, appid: str = "") -> int:
144+
if not appid and isinstance(self._session.cfg, AppConfig):
145+
appid = self._session.cfg.app_name
146+
else:
147+
raise ValueError("The `appid` parameter cannot be empty for non-ExApp use.")
148+
return self._session.ocs("DELETE", f"{self._ep_base}/byappid/{appid}")
149+
143150

144151
class _AsyncWebhooksAPI:
145152
"""The class provides the async application management API on the Nextcloud server."""
@@ -208,3 +215,10 @@ async def update(
208215

209216
async def unregister(self, webhook_id: int) -> bool:
210217
return await self._session.ocs("DELETE", f"{self._ep_base}/{webhook_id}")
218+
219+
async def unregister_all(self, appid: str = "") -> int:
220+
if not appid and isinstance(self._session.cfg, AppConfig):
221+
appid = self._session.cfg.app_name
222+
else:
223+
raise ValueError("The `appid` parameter cannot be empty for non-ExApp use.")
224+
return await self._session.ocs("DELETE", f"{self._ep_base}/byappid/{appid}")

0 commit comments

Comments
 (0)
Please sign in to comment.