Skip to content

Commit

Permalink
added "webhooks.unregister_all" (#309)
Browse files Browse the repository at this point in the history
Mainly needed for ExApps, but can also be used in some scripts with
admin rights.

---------

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
  • Loading branch information
bigcat88 authored Oct 9, 2024
1 parent 0750270 commit 39aa8db
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 53 deletions.
62 changes: 11 additions & 51 deletions .github/workflows/analysis-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ jobs:
strategy:
fail-fast: false
matrix:
nextcloud: [ 'stable28', 'stable29', 'master' ]
nextcloud: [ 'stable28', 'stable29', 'stable30' ]
timeout-minutes: 60

services:
Expand Down Expand Up @@ -483,15 +483,13 @@ jobs:

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

- name: Checkout Files Locking
uses: actions/checkout@v4
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
with:
repository: nextcloud/files_lock
ref: ${{ matrix.nextcloud }}
Expand All @@ -511,11 +509,9 @@ jobs:
PHP_CLI_SERVER_WORKERS=2 php -S localhost:8080 &
- name: Enable Files Locking
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
run: ./occ app:enable files_lock

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

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

- name: Checkout AppAPI
if: ${{ matrix.nextcloud != 'master' }}
if: ${{ matrix.nextcloud != 'stable30' }}
uses: actions/checkout@v4
with:
path: apps/app_api
repository: nextcloud/app_api
ref: stable29

- name: Checkout AppAPI
if: ${{ matrix.nextcloud == 'master' }}
if: ${{ matrix.nextcloud == 'stable30' }}
uses: actions/checkout@v4
with:
path: apps/app_api
repository: nextcloud/app_api
ref: stable30

- name: Install AppAPI
run: |
Expand All @@ -555,20 +552,12 @@ jobs:
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
- name: Talk Branch Main
if: ${{ startsWith(matrix.nextcloud, 'master') }}
run: echo "TALK_BRANCH_NAME=main" >> $GITHUB_ENV

- name: Talk Branch Other
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
run: echo "TALK_BRANCH_NAME=${{ matrix.nextcloud }}" >> $GITHUB_ENV

- name: Checkout Talk
uses: actions/checkout@v4
with:
path: apps/spreed
repository: nextcloud/spreed
ref: ${{ env.TALK_BRANCH_NAME }}
ref: ${{ matrix.nextcloud }}

- name: Install Talk
working-directory: apps/spreed
Expand Down Expand Up @@ -627,7 +616,7 @@ jobs:
strategy:
fail-fast: false
matrix:
nextcloud: [ 'stable28', 'stable29', 'master' ]
nextcloud: [ 'stable28', 'stable29', 'stable30' ]
env:
NC_dbname: nextcloud_abz
DATABASE_PGSQL: 1
Expand Down Expand Up @@ -704,19 +693,20 @@ jobs:
run: python3 -m pip -v install ".[dev]"

- name: Checkout AppAPI
if: ${{ matrix.nextcloud != 'master' }}
if: ${{ matrix.nextcloud != 'stable30' }}
uses: actions/checkout@v4
with:
path: apps/app_api
repository: nextcloud/app_api
ref: stable29

- name: Checkout AppAPI
if: ${{ matrix.nextcloud == 'master' }}
if: ${{ matrix.nextcloud == 'stable30' }}
uses: actions/checkout@v4
with:
path: apps/app_api
repository: nextcloud/app_api
ref: stable30

- name: Install AppAPI
run: |
Expand All @@ -731,20 +721,12 @@ jobs:
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
- name: Talk Branch Main
if: ${{ startsWith(matrix.nextcloud, 'master') }}
run: echo "TALK_BRANCH_NAME=main" >> $GITHUB_ENV

- name: Talk Branch Other
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
run: echo "TALK_BRANCH_NAME=${{ matrix.nextcloud }}" >> $GITHUB_ENV

- name: Checkout Talk
uses: actions/checkout@v4
with:
path: apps/spreed
repository: nextcloud/spreed
ref: ${{ env.TALK_BRANCH_NAME }}
ref: ${{ matrix.nextcloud }}

- name: Install Talk
working-directory: apps/spreed
Expand Down Expand Up @@ -808,7 +790,7 @@ jobs:
strategy:
fail-fast: false
matrix:
nextcloud: [ 'stable27', 'stable28', 'stable29', 'master' ]
nextcloud: [ 'stable27', 'stable28', 'stable29', 'stable30', 'master' ]
env:
NEXTCLOUD_URL: "http://localhost:8080/index.php"
timeout-minutes: 60
Expand Down Expand Up @@ -884,28 +866,6 @@ jobs:
working-directory: nc_py_api
run: python3 -m pip -v install . pytest pytest-asyncio coverage pillow

- name: Talk Branch Main
if: ${{ startsWith(matrix.nextcloud, 'master') }}
run: echo "TALK_BRANCH_NAME=main" >> $GITHUB_ENV

- name: Talk Branch Other
if: ${{ !startsWith(matrix.nextcloud, 'master') }}
run: echo "TALK_BRANCH_NAME=${{ matrix.nextcloud }}" >> $GITHUB_ENV

- name: Checkout Talk
uses: actions/checkout@v4
with:
path: apps/spreed
repository: nextcloud/spreed
ref: ${{ env.TALK_BRANCH_NAME }}

- name: Install Talk
working-directory: apps/spreed
run: make dev-setup

- name: Enable Talk
run: php occ app:enable spreed

- name: Generate coverage report
working-directory: nc_py_api
run: coverage run -m pytest && coverage xml -o coverage_sqlite_${{ matrix.nextcloud }}_client.xml
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ answer newbie questions, and generally made NC-Py-API that much better:
Alexander Piskun <bigcat88@icloud.com>
CooperGerman <https://github.com/CooperGerman>
Tobias Tschech <Tobias@tschech-online.de>
Scott Williams <scottwilliams@ucsb.edu>
<Please alphabetize new entries>

A big THANK YOU goes to:
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

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

## [0.18.0 - 2024-10-09]

### Added

- New `webhooks.unregister_all` method. #309

### Fixed

- Files: `user` and `user_path` properties in `FSNode` when Nextcloud located in in sub-path. #297 Thanks to @vwbusguy
- `files.download_directory_as_zip` method now supports upcoming Nextcloud 31. #304

## [0.17.1 - 2024-09-06]

### Added
Expand Down
2 changes: 1 addition & 1 deletion nc_py_api/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version of nc_py_api."""

__version__ = "0.17.1"
__version__ = "0.18.0.dev0"
16 changes: 15 additions & 1 deletion nc_py_api/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dataclasses

from ._misc import clear_from_params_empty # , require_capabilities
from ._session import AsyncNcSessionBasic, NcSessionBasic
from ._session import AppConfig, AsyncNcSessionBasic, NcSessionBasic


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

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


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

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

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

0 comments on commit 39aa8db

Please sign in to comment.