Skip to content

Conversation

@come-nc
Copy link
Contributor

@come-nc come-nc commented Mar 13, 2025

Summary

Fix pubilc download activity in 31+, and improve upon it to make sure it’s consistent.

TODO

  • Viewing a video triggers several activity events. They are merged in activity feed, but generate a lot of notifications.
  • Viewing a photo through preview does not trigger activity, is that an issue?
  • Downloading the whole share triggers activity for the folder and then for each file.
  • Downloading several files in a zip triggers activity for each file. I think that’s good?
  • The manual activity publishing in ShareController should be removed to avoid duplicates. But I think that’s the one publishing the activity for folder download, so we should make sure we do not lose it.

Checklist

@come-nc come-nc added the 2. developing Work in progress label Mar 13, 2025
@come-nc come-nc added this to the Nextcloud 32 milestone Mar 13, 2025
@come-nc come-nc requested review from skjnldsv and susnux March 13, 2025 11:16
@come-nc come-nc self-assigned this Mar 13, 2025
@come-nc
Copy link
Contributor Author

come-nc commented Mar 13, 2025

  • Viewing a photo through preview does not trigger activity, is that an issue?

This one is not a regression so let’s postpone for later.
A solution would be to listen to BeforePreviewFetchedEvent, but we’d have to decide at which size of preview we consider that downloading, because opening the file list already loads previews of small sizes.

@come-nc
Copy link
Contributor Author

come-nc commented Mar 13, 2025

/backport to stable31

@come-nc come-nc marked this pull request as ready for review March 13, 2025 16:42
@come-nc come-nc requested a review from a team as a code owner March 13, 2025 16:42
@come-nc come-nc requested review from ArtificialOwl and yemkareems and removed request for a team March 13, 2025 16:42
@come-nc come-nc added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Mar 13, 2025
@come-nc
Copy link
Contributor Author

come-nc commented Mar 13, 2025

I would like to add tests for this, but activity application is needed.
I can add the tests in activity application cypress tests, but that mean a PR breaking the feature on server will have green CI and we will only figure it out later. Still better than no tests I suppose?
Other ideas?

@susnux
Copy link
Contributor

susnux commented Mar 13, 2025

I would like to add tests for this, but activity application is needed.

Is there no OCS API or something you can test with behat?

Otherwise I see two ways:

  1. Do it like we do for some Talk tests and install the Activity for some Behat tests (IMHO this makes sense for all things that have integrations in OCP)
  2. Only add them to Activity -> would not be directly spotted if something breaks the app.

@daniel-richter
Copy link

Just a heads-up: I had the same issue (downloads of individual files from a shared folder weren't showing up in the activities, #51097). I can confirm that the suggested changes solve the problem for me.

@daniel-richter
Copy link

daniel-richter commented Mar 16, 2025

  • Viewing a video triggers several activity events. They are merged in activity feed, but generate a lot of notifications.
  • Viewing a photo through preview does not trigger activity, is that an issue?

Well, that's how it used to be. If you watched a video, it would show up in the "downloaded via public link" log. For images, you had to click "download" for it to show up in the log. Just viewing the image didn't do it.

For me, it's more important to see the explicit downloads (of an image) instead of just viewing it in the gallery. If both are to be logged, I'd prefer to see two different events ("viewed" and "downloaded").

@susnux
Copy link
Contributor

susnux commented Mar 16, 2025

Did not yet had time to test this, but old behavior was also inconsistent as there were some endpoints that never caused a download notification.
Also we should define what this notification means.

Because either it only means real downloads, then we only need to track the DAV endpoints (GET on file or zipfolder plugin).
Or it also means viewing the file, then we also need to track preview endpoints (which is used by the viewer for images).

If I get the code right then this PR implements both. Which is fine but might confuse users as they will see "file downloaded" notifications even if they set "download permission" to false because previews are shown.

@daniel-richter
Copy link

I see two options here:

  1. Track only real downloads.
  2. If we want to track views, too, we should introduce a separate subject, "public_shared_file_viewed" (in contrast to "public_shared_file_downloaded").

@come-nc
Copy link
Contributor Author

come-nc commented Mar 17, 2025

I would like to add tests for this, but activity application is needed.

Is there no OCS API or something you can test with behat?

It’s DAV, not OCS, but that can be tested with behat. But still needs the activity app.

Otherwise I see two ways:

  1. Do it like we do for some Talk tests and install the Activity for some Behat tests (IMHO this makes sense for all things that have integrations in OCP)

I will try that.

If I get the code right then this PR implements both. Which is fine but might confuse users as they will see "file downloaded" notifications even if they set "download permission" to false because previews are shown.

No, this PR only logs downloads through DAV, kind of the same as old behavior.
Preview endpoint does not trigger any notifications. (edit: Well, dav and the legacy ocs endpoint as well, any request that reads the file actually)

Actually, something I did not test is if a public link is loaded in which there is a file with no preview yet. Then opening the folder may trigger the preview computing and a download activity. But I’m not 100% sure that is possible in real life. How do you share a folder without triggering preview caching?

@susnux
Copy link
Contributor

susnux commented Mar 17, 2025

Actually, something I did not test is if a public link is loaded in which there is a file with no preview yet. Then opening the folder may trigger the preview computing and a download activity. But I’m not 100% sure that is possible in real life. How do you share a folder without triggering preview caching?

Opening an image in viewer also always triggers new preview generation as the image shown in viewer is basically a big preview. Thats what I meant with "view activity"

@come-nc come-nc force-pushed the fix/fix-public-download-activity branch 2 times, most recently from 94802cf to eb5ad83 Compare March 18, 2025 15:27
@come-nc come-nc requested review from nickvergessen and susnux March 18, 2025 15:28
@come-nc come-nc force-pushed the fix/fix-public-download-activity branch from d8b2603 to 4fbff98 Compare March 25, 2025 09:35
@come-nc come-nc requested a review from nickvergessen March 25, 2025 09:36
@come-nc come-nc force-pushed the fix/fix-public-download-activity branch from 4fbff98 to eb5ad83 Compare March 25, 2025 14:00
come-nc added 9 commits March 25, 2025 15:43
Even if dav endpoint is now used.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Remove duplicate activity publishing from share controller download,
 listen to BeforeZipCreatedEvent to publish activity for folders, and
 cache folders activity to avoid sending activity for each file in the
 folder.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
…e file

Avoids flooding activities when someone browse a video in the web player.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
…the request

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
…urrency issues

If several people are watching and seeking the same video file we do not
 want the cache key to be the same or it would flood activity again.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Fixes "Object for placeholder file is invalid, value 21 for key id is not a string"
Exception spotted in tests logs.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc come-nc force-pushed the fix/fix-public-download-activity branch from eb5ad83 to da9b6e3 Compare March 25, 2025 14:43
@susnux susnux merged commit efa5632 into master Mar 25, 2025
198 of 207 checks passed
@susnux susnux deleted the fix/fix-public-download-activity branch March 25, 2025 19:58
@nextcloud-bot nextcloud-bot mentioned this pull request Aug 19, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: NC31.0.0 not logging view/download activity

7 participants