Skip to content

feat(files): add an API to report that a user opened a file - #65994

Merged
skjnldsv merged 3 commits into
masterfrom
feature/node-opened-event
Oct 29, 2026
Merged

skjnldsv merged 3 commits into
masterfrom
feature/node-opened-event

Conversation

@skjnldsv

@skjnldsv skjnldsv commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Reading a file isn't opening it. BeforeNodeReadEvent fires for sync clients, previews and downloads, so apps can't tell what a user actually works with.

This adds POST /ocs/v2.php/apps/files/api/v1/opened with a fileId. It dispatches a new NodeOpenedEvent with the node and the user. It's public on purpose, so the viewer, the "Open locally" action and desktop/mobile clients can all report opens. Recommendations will use it for recent and frequent files.

Folders are accepted too. The rate limit (100/min per user) is a guess, happy to adjust.

curl -u alice:alice -X POST -H 'OCS-APIRequest: true' -H 'Content-Type: application/json' \
  -d '{"fileId":52}' https://cloud/ocs/v2.php/apps/files/api/v1/opened
{"ocs":{"meta":{"status":"ok","statuscode":200,"message":"OK"},"data":[]}}

Next

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

👾 This pull request was assisted by Claude Code, commits carry an Assisted-by trailer.

Reading a file is not opening it: sync clients, previews and downloads
all fire BeforeNodeReadEvent. Clients can now call
POST /ocs/v2.php/apps/files/api/v1/opened when the user actually opens
a file or folder, which dispatches a NodeOpenedEvent apps can listen to.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
@skjnldsv skjnldsv self-assigned this Oct 29, 2026
@skjnldsv
skjnldsv marked this pull request as ready for review October 29, 2026 02:56
@skjnldsv skjnldsv removed the 2. developing Work in progress label Oct 29, 2026
@skjnldsv skjnldsv added the 3. to review Waiting for reviews label Oct 29, 2026
@skjnldsv
skjnldsv requested a review from a team as a code owner October 29, 2026 02:56
@skjnldsv
skjnldsv requested review from icewind1991, leftybournes and sorbaugh and removed request for a team October 29, 2026 02:56
@skjnldsv

Copy link
Copy Markdown
Member Author

Ready! it's quite straightforward :)

Comment thread lib/public/Files/Events/Node/NodeOpenedEvent.php
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
Clients report opens when they choose to, so the event can be missing,
repeated, or sent for a node the user never looked at. Make clear it
must not be used for permissions, access control or auditing.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
@skjnldsv

Copy link
Copy Markdown
Member Author

CI failures are unrelated: the PHPUnit ones fail the same way on other PRs today (e.g. https://github.com/nextcloud/server/actions/runs/40871288892), Azure fails on Azurite XML parsing, and Playwright passed on re-run.

@skjnldsv
skjnldsv merged commit f66f729 into master Oct 29, 2026
176 of 187 checks passed
@skjnldsv
skjnldsv deleted the feature/node-opened-event branch October 29, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants