Skip to content

Conversation

@grnd-alt
Copy link
Member

@grnd-alt grnd-alt commented Oct 8, 2024

Summary

Dav api did not log favorite added/removed events.

Checklist

@grnd-alt grnd-alt force-pushed the fix/activity-log-for-favorites-in-dav branch from cde368c to e747f11 Compare October 8, 2024 10:56
@szaimen szaimen requested review from artonge and removed request for szaimen October 8, 2024 11:32
@szaimen szaimen added enhancement 3. to review Waiting for reviews labels Oct 8, 2024
@szaimen szaimen added this to the Nextcloud 31 milestone Oct 8, 2024
@grnd-alt grnd-alt force-pushed the fix/activity-log-for-favorites-in-dav branch 3 times, most recently from 3a2b521 to fbd6419 Compare October 8, 2024 12:55
Copy link
Contributor

@susnux susnux left a comment

Choose a reason for hiding this comment

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

Would it not be cleaner and make more sense to emit just the event and handle the activity in an event listener?

Then only one place for the activity is required and one would not mix different apps (files app activity in dav app).

Copy link
Contributor

@artonge artonge left a comment

Choose a reason for hiding this comment

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

I don't get why this is need. Isn't TagService already doing that?

protected function addActivity($addToFavorite, $fileId, $path) {
$user = $this->userSession->getUser();
if (!$user instanceof IUser) {
return;
}
if ($addToFavorite) {
$event = new NodeAddedToFavorite($user, $fileId, $path);
} else {
$event = new NodeRemovedFromFavorite($user, $fileId, $path);
}
$this->dispatcher->dispatchTyped($event);
$event = $this->activityManager->generateEvent();
try {
$event->setApp('files')
->setObject('files', $fileId, $path)
->setType('favorite')
->setAuthor($user->getUID())
->setAffectedUser($user->getUID())
->setTimestamp(time())
->setSubject(
$addToFavorite ? FavoriteProvider::SUBJECT_ADDED : FavoriteProvider::SUBJECT_REMOVED,
['id' => $fileId, 'path' => $path]
);
$this->activityManager->publish($event);
} catch (\InvalidArgumentException $e) {
} catch (\BadMethodCallException $e) {
}
}
}

EDIT: reading the issue

@grnd-alt grnd-alt force-pushed the fix/activity-log-for-favorites-in-dav branch 4 times, most recently from 935e3b1 to e61f394 Compare October 14, 2024 08:29
@grnd-alt grnd-alt self-assigned this Oct 15, 2024
@grnd-alt grnd-alt force-pushed the fix/activity-log-for-favorites-in-dav branch 7 times, most recently from 739acab to 6f98dd1 Compare October 22, 2024 14:18
@grnd-alt grnd-alt force-pushed the fix/activity-log-for-favorites-in-dav branch from 6f98dd1 to 205809a Compare October 22, 2024 15:53
@grnd-alt grnd-alt requested review from artonge and susnux October 29, 2024 09:12
@grnd-alt grnd-alt force-pushed the fix/activity-log-for-favorites-in-dav branch from e96dc20 to ee093f5 Compare November 7, 2024 10:01
$this->eventDispatcher->dispatchTyped(new NodeAddedToFavorite($this->userSession->getUser(), $node->getId(), $path));
} else {
$this->getTagger()->unTag($node->getId(), self::TAG_FAVORITE);
$this->eventDispatcher->dispatchTyped(new NodeRemovedFromFavorite($this->userSession->getUser(), $node->getId(), $path));
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it make sense to dispatch the events in the tagAs and unTag methods in

public function tagAs($objid, $tag) {
?

I cannot judge if there are cases where we don't want that, but if not we could save duplicate calls in https://github.com/nextcloud/server/pull/48612/files#diff-d2d90fa28b8b1a36f0664fa4a25a0753a765a824d0bd2524e7457d5be7a2d7a5R62 and potentially forgetting about code paths that should also store an activity entry.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we always want activities for tags, no?
So I agree with your comment :)

Copy link
Member

@juliusknorr juliusknorr left a comment

Choose a reason for hiding this comment

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

Looks good, left one comment where I'm not familiar enough with the code paths to judge

Copy link
Contributor

@susnux susnux left a comment

Choose a reason for hiding this comment

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

Looks good!
Also Julius suggestion makes sense.

@grnd-alt grnd-alt force-pushed the fix/activity-log-for-favorites-in-dav branch from dc5e8fd to 849a28a Compare November 19, 2024 11:05
@juliusknorr
Copy link
Member

Failure looks related


There was 1 failure:

1) OCA\Files\Tests\Service\TagServiceTest::testFavoriteActivity
Expectation failed for method name is "dispatchTyped" when invoked 2 time(s).
Method was expected to be called 2 times, actually called 0 times.

Signed-off-by: grnd-alt <salimbelakkaf@outlook.de>
Signed-off-by: grnd-alt <salimbelakkaf@outlook.de>
@grnd-alt grnd-alt force-pushed the fix/activity-log-for-favorites-in-dav branch from 849a28a to 8d953ae Compare December 3, 2024 19:56
Signed-off-by: grnd-alt <github@belakkaf.net>
@grnd-alt
Copy link
Member Author

@susnux @juliusknorr I've added a commit after your reviews, idk if I should merge without confirmation from one of you

@juliusknorr juliusknorr merged commit cba556d into master Dec 12, 2024
188 checks passed
@juliusknorr juliusknorr deleted the fix/activity-log-for-favorites-in-dav branch December 12, 2024 14:18
@skjnldsv skjnldsv mentioned this pull request Jan 7, 2025
artonge added a commit that referenced this pull request Sep 15, 2025
The `$path` argument was added in #48612, but was never actually used by the callers. The path was therefore missing in the favorite/unfavorite events, which lead to a broken activity information.

I also added a fallback to handle `addToFavorites` and `removeFromFavorites`, which are part of a public API, and are calling `tagAs` and `untag` without `$path`.

Fix https://github.com/nextcloud/server/issues/55118

Signed-off-by: Louis Chemineau <louis@chmn.me>
artonge added a commit that referenced this pull request Sep 15, 2025
The `$path` argument was added in #48612, but was never actually used by the callers. The path was therefore missing in the favorite/unfavorite events, which lead to a broken activity information.

I also added a fallback to handle `addToFavorites` and `removeFromFavorites`, which are part of a public API, and are calling `tagAs` and `untag` without `$path`.

Fix https://github.com/nextcloud/server/issues/55118

Signed-off-by: Louis Chemineau <louis@chmn.me>
artonge added a commit that referenced this pull request Sep 15, 2025
The `$path` argument was added in #48612, but was never actually used by the callers. The path was therefore missing in the favorite/unfavorite events, which lead to a broken activity information.

I also added a fallback to handle `addToFavorites` and `removeFromFavorites`, which are part of a public API, and are calling `tagAs` and `untag` without `$path`.

Fix nextcloud/activity#2134

Signed-off-by: Louis Chemineau <louis@chmn.me>
artonge added a commit that referenced this pull request Sep 15, 2025
The `$path` argument was added in #48612, but was never actually used by the callers. The path was therefore missing in the favorite/unfavorite events, which lead to a broken activity information.

I also added a fallback to handle `addToFavorites` and `removeFromFavorites`, which are part of a public API, and are calling `tagAs` and `untag` without `$path`.

Fix nextcloud/activity#2134

Signed-off-by: Louis Chemineau <louis@chmn.me>
artonge added a commit that referenced this pull request Sep 15, 2025
The `$path` argument was added in #48612, but was never actually used by the callers. The path was therefore missing in the favorite/unfavorite events, which lead to a broken activity information.

I also added a fallback to handle `addToFavorites` and `removeFromFavorites`, which are part of a public API, and are calling `tagAs` and `untag` without `$path`.

Fix nextcloud/activity#2134

Signed-off-by: Louis Chemineau <louis@chmn.me>
artonge added a commit that referenced this pull request Sep 15, 2025
The `$path` argument was added in #48612, but was never actually used by the callers. The path was therefore missing in the favorite/unfavorite events, which lead to a broken activity information.

I also added a fallback to handle `addToFavorites` and `removeFromFavorites`, which are part of a public API, and are calling `tagAs` and `untag` without `$path`.

Fix nextcloud/activity#2134

Signed-off-by: Louis Chemineau <louis@chmn.me>
artonge added a commit that referenced this pull request Sep 15, 2025
The `$path` argument was added in #48612, but was never actually used by the callers. The path was therefore missing in the favorite/unfavorite events, which lead to a broken activity information.

I also added a fallback to handle `addToFavorites` and `removeFromFavorites`, which are part of a public API, and are calling `tagAs` and `untag` without `$path`.

Fix nextcloud/activity#2134

Signed-off-by: Louis Chemineau <louis@chmn.me>
artonge added a commit that referenced this pull request Sep 15, 2025
The `$path` argument was added in #48612, but was never actually used by the callers. The path was therefore missing in the favorite/unfavorite events, which lead to a broken activity information.

I also added a fallback to handle `addToFavorites` and `removeFromFavorites`, which are part of a public API, and are calling `tagAs` and `untag` without `$path`.

Fix nextcloud/activity#2134

Signed-off-by: Louis Chemineau <louis@chmn.me>
backportbot bot pushed a commit that referenced this pull request Sep 15, 2025
The `$path` argument was added in #48612, but was never actually used by the callers. The path was therefore missing in the favorite/unfavorite events, which lead to a broken activity information.

I also added a fallback to handle `addToFavorites` and `removeFromFavorites`, which are part of a public API, and are calling `tagAs` and `untag` without `$path`.

Fix nextcloud/activity#2134

Signed-off-by: Louis Chemineau <louis@chmn.me>

[skip ci]
backportbot bot pushed a commit that referenced this pull request Sep 15, 2025
The `$path` argument was added in #48612, but was never actually used by the callers. The path was therefore missing in the favorite/unfavorite events, which lead to a broken activity information.

I also added a fallback to handle `addToFavorites` and `removeFromFavorites`, which are part of a public API, and are calling `tagAs` and `untag` without `$path`.

Fix nextcloud/activity#2134

Signed-off-by: Louis Chemineau <louis@chmn.me>
artonge added a commit that referenced this pull request Sep 15, 2025
The `$path` argument was added in #48612, but was never actually used by the callers. The path was therefore missing in the favorite/unfavorite events, which lead to a broken activity information.

I also added a fallback to handle `addToFavorites` and `removeFromFavorites`, which are part of a public API, and are calling `tagAs` and `untag` without `$path`.

Fix nextcloud/activity#2134

Signed-off-by: Louis Chemineau <louis@chmn.me>
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 enhancement

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Missing activity for favorites via WebDAV

6 participants