Skip to content

Conversation

@dev-KingMaster
Copy link

@dev-KingMaster dev-KingMaster commented Nov 5, 2025

Description:

Related issue (if applicable): #1111
Add group and everyone targeting to the Nextcloud plugin:

  • Group targets via #GroupName (e.g., .../#DevTeam)
  • Everyone via all (aliases: everyone, *)
  • Resolve users using OCS v1 JSON (/ocs/v1.php/cloud/groups/?format=json, /ocs/v1.php/cloud/users?format=json)
  • Deduplicate targets to avoid duplicates
  • Tests added and lints fixed; README kept minimal per maintainer guidance

Nextcloud Notifications (Enhancement)

  • Source: https://nextcloud.com/
  • Icon Support: No (Nextcloud client renders its own icon)
  • Message Format: Plain Text
  • Message Limit: Title 255 chars, Body 4000 chars

This enhancement allows sending notifications to:

  • Individual users (unchanged)
  • A group using #GroupName
  • Everyone using all (aliases: everyone, *)
    Internally, Apprise expands group/everyone to user IDs via the OCS provisioning API (over HTTP or HTTPS, depending on ncloud/nclouds) and sends one notification per unique user.

🛠️ Setup Instructions

  • Enable provisioning API: occ app:enable provisioning_api
  • Use credentials permitted to list users (typically admin)
  • If hosted under a sub-path, set url_prefix (e.g., ?url_prefix=/nextcloud)

📦 Examples
Users:

apprise -vv -t "Title" -b "Message" \
  "ncloud://admin:pass@host/user1/user2"

Group:

apprise -vv -t "Title" -b "Message" \
  "ncloud://admin:pass@host/#DevTeam"

Everyone:

apprise -vv -t "Title" -b "Message" \
  "ncloud://admin:pass@host/all"

Mixed (deduplicated):

apprise -vv -t "Title" -b "Message" \
  "ncloud://admin:pass@host/#DevTeam/user3/all"

Sub-path:

apprise -vv -t "Title" -b "Message" \
  "ncloud://admin:pass@host:8080/#Ops?url_prefix=/nextcloud"

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (tox -e lint).
  • Test coverage added (tests/test_plugin_nextcloud.py).

Contribution by Gittensor, learn more at https://gittensor.io/

@caronc caronc requested a review from Copilot November 5, 2025 03:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for targeting groups and all users in Nextcloud notifications, expanding the plugin's functionality to resolve special target patterns into individual user notifications.

Key changes:

  • Added _resolve_targets() method to expand group:<name> and all keywords into individual user targets using Nextcloud's OCS provisioning API
  • Enhanced documentation to explain the new targeting features
  • Added comprehensive test coverage for group and all-user expansion

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
apprise/plugins/nextcloud.py Implements group/all-user expansion via OCS API with JSON/XML fallback parsing
tests/test_plugin_nextcloud.py Adds test cases for group and all-user target resolution with mocked API responses
README.md Documents new targeting syntax and requirements for using groups and all-user expansion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 86.31579% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.59%. Comparing base (91b6f91) to head (d6a0f7b).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
apprise/plugins/nextcloud.py 86.31% 9 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1440      +/-   ##
==========================================
- Coverage   99.65%   99.59%   -0.06%     
==========================================
  Files         174      174              
  Lines       22561    22648      +87     
  Branches     3590     3604      +14     
==========================================
+ Hits        22483    22557      +74     
- Misses         70       79       +9     
- Partials        8       12       +4     
Files with missing lines Coverage Δ
apprise/plugins/nextcloud.py 93.22% <86.31%> (-6.78%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Owner

@caronc caronc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean... Is this working for you right now?

The code tries multiple endpoints and trys to parse in XML and falls gracefully...

I don't use nextcloud personally, so I can't make a good judgement call. But it just seems very odd... Is each version of the tool so different then the next, that so many workarounds need to be tested to get the list of users?

@dev-KingMaster
Copy link
Author

dev-KingMaster commented Nov 5, 2025

Yeah, I used local NextCloud for testing and it worked well. The concern here is complexity due to several fallbacks.
I agree the fallbacks are more than we need. I’ll simplify to the documented v1.php OCS endpoints with ‘?format=json' which I tested and confirmed it is working.
Thanks for reviewing!

@dev-KingMaster
Copy link
Author

Thanks for the review — I simplified the resolver as suggested. It now uses only the v1 OCS endpoints with JSON:

  • Groups: /ocs/v1.php/cloud/groups/?format=json
  • Users: /ocs/v1.php/cloud/users?format=json
  • I removed XML and v2 fallbacks, and tightened the loop to iterate directly over resolved targets.
  • I switched group targets to use hash‑prefix (e.g., #DevTeam), added a target_group token alias, and updated tests/docs. README large section was removed per your note
  • I re‑validated locally against nextcloud:apache and existing unit tests; patch coverage is strong now and all tests pass.

@dev-KingMaster
Copy link
Author

@caronc _resolve_targets simplified a lot and you can easily get the gist out of it now.

@caronc
Copy link
Owner

caronc commented Nov 6, 2025

I did a little refactoring to your code (not much); still need to add more test coverage; but i can help with this. I introduced the use of caching so the user lists do not have to fetch over and over again once already known

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants