Skip to content

fix(dav): Skip CalDAV activities for resource and room calendars - #67687

Open
kukanggg89 wants to merge 1 commit into
nextcloud:masterfrom
kukanggg89:fix-dav-activity-non-user-principals-67518
Open

kukanggg89 wants to merge 1 commit into
nextcloud:masterfrom
kukanggg89:fix-dav-activity-non-user-principals-67518

Conversation

@kukanggg89

Copy link
Copy Markdown
Contributor

Summary

The CalDAV activity backend took the calendar owner from the last segment of principaluri without checking the principal type, so an event delivered to a resource or room calendar created activities for a user that does not exist. For long resource IDs the activity failed outright (affected user over 64 characters) and the failure landed in the log as an error.

The four methods that derive the owner from principaluri now return early unless the principal starts with principals/users/: triggerCalendarActivity, onCalendarUpdateShares, onTouchCalendarObject, and onMovedCalendarObject. The new check lives in one helper, isUserCalendar(). One edge case stays working: moving an object between two calendars with different owners still reports the delete side for a user calendar, because the cross-owner path goes through onTouchCalendarObject and each side is checked on its own.

The existing test fixtures used principal/user/admin, which is not a real principal URI; they now use principals/users/admin.

TODO

None.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tests (unit, integration, api and/or acceptance) are included
  • Screenshots before/after for front-end changes (n/a: no front-end change)
  • Documentation (manuals or wiki) has been updated or is not required (n/a: no user-facing behaviour change beyond dropping bogus activities)
  • Backports requested where applicable (ex: critical bugfixes) (n/a: bugfix, backport decision left to maintainers)
  • Labels added where applicable (ex: bug/enhancement, 3. to review, feature component) (n/a: maintainers set labels)
  • Milestone added for target branch/version (ex: 32.x for stable32) (n/a: maintainers set the milestone)

AI (if applicable)

Drafted with help from Claude. I reviewed and revised every change myself before opening this PR.

Verification

Five new test methods (13 cases) in BackendTest: resource and room principals, including a resource ID of 84 characters, create no activity in triggerCalendarActivity, onTouchCalendarObject, onCalendarUpdateShares, and onMovedCalendarObject, plus a positive test that a user calendar still gets its object activity. The guard logic was checked by hand against every principaluri value in the test file. The test suite was not run locally (no PHP toolchain in this environment); CI runs it. Not validated on a live instance.

The CalDAV activity backend took the calendar owner from the last
segment of principaluri without checking the principal type, so events
delivered to a resource or room calendar created activities for a
user that does not exist. Long resource IDs failed outright with the
affected user over 64 characters and an error in the log.

Return early from the methods that derive the owner from
principaluri unless the principal starts with principals/users/:
triggerCalendarActivity, onCalendarUpdateShares,
onTouchCalendarObject and onMovedCalendarObject. A move between two
calendars with different owners still reports the delete side for a
user calendar through onTouchCalendarObject.

Adds unit tests in BackendTest: resource and room principals
(including a resource ID over 64 characters) create no activity in
any of the four methods, plus a positive test that a user calendar
still gets its activity. The existing fixtures used the unrealistic
principaluri principal/user/admin, updated to principals/users/admin.

Signed-off-by: parel <farelalfarizi89@gmail.com>
Assisted-by: Muse:Muse Spark 1.3

This branch has not been deployed

No deployments
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.

DAV activity backend treats resource and room principals as users

1 participant