Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing activity for favorites via WebDAV #26393

Open
MorrisJobke opened this issue Mar 31, 2021 · 4 comments · May be fixed by #48612
Open

Missing activity for favorites via WebDAV #26393

MorrisJobke opened this issue Mar 31, 2021 · 4 comments · May be fixed by #48612

Comments

@MorrisJobke
Copy link
Member

  • mark a file as favorite via WebDAV (Android or iOS app for example)
  • open the activity view
  • expected: "You have favorited FILE"
  • actual: no activity

The web UI uses apps/files/api/v1/files/FILE API that does trigger the activity.

The code to add the tag:

public function updateFileTags($path, $tags) {
$fileId = $this->homeFolder->get($path)->getId();
$currentTags = $this->tagger->getTagsForObjects([$fileId]);
if (!empty($currentTags)) {
$currentTags = current($currentTags);
}
$newTags = array_diff($tags, $currentTags);
foreach ($newTags as $tag) {
if ($tag === ITags::TAG_FAVORITE) {
$this->addActivity(true, $fileId, $path);
}
$this->tagger->tagAs($fileId, $tag);
}
$deletedTags = array_diff($currentTags, $tags);
foreach ($deletedTags as $tag) {
if ($tag === ITags::TAG_FAVORITE) {
$this->addActivity(false, $fileId, $path);
}
$this->tagger->unTag($fileId, $tag);
}
// TODO: re-read from tagger to make sure the
// list is up to date, in case of concurrent changes ?
return $tags;
}

And then the actitivity:

protected function addActivity($addToFavorite, $fileId, $path) {
$user = $this->userSession->getUser();
if (!$user instanceof IUser) {
return;
}
$eventName = $addToFavorite ? 'addFavorite' : 'removeFavorite';
$this->dispatcher->dispatch(self::class . '::' . $eventName, new GenericEvent(null, [
'userId' => $user->getUID(),
'fileId' => $fileId,
'path' => $path,
]));
$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) {
}
}

While the PROPPATCH doesn't trigger anything related to that:

if ((int)$favState === 1 || $favState === 'true') {
$this->getTagger()->tagAs($node->getId(), self::TAG_FAVORITE);
} else {
$this->getTagger()->unTag($node->getId(), self::TAG_FAVORITE);
}
if (is_null($favState)) {
// confirm deletion
return 204;
}
return 200;

How to handle this? The ugly way by making tthe method in TagService public and call from the dav app directly into the files app to have it all in one place, or to copy it over and deprecated the files app approach as we should go for DAV based API access anyways? I would say option 2.

cc @rullzer @ChristophWurst @kesselb @PVince81 @juliushaertl

@MorrisJobke MorrisJobke added bug 1. to develop Accepted and waiting to be taken care of labels Mar 31, 2021
@MorrisJobke MorrisJobke added this to the Nextcloud 22 milestone Mar 31, 2021
@rullzer
Copy link
Member

rullzer commented Apr 1, 2021

It is webdav. So I consider this a core app. I'd be fine to call an internal function.

Long term we should move it all to DAV and kill the dedicatd endpoint IMO

@MorrisJobke
Copy link
Member Author

Long term we should move it all to DAV and kill the dedicatd endpoint IMO

Yep, but then we can also copy it over now and then just deprecate the old method :) Nothing lost and avoided unnecessary complexity that we need to reduce in the future again.

@rullzer
Copy link
Member

rullzer commented Apr 1, 2021

Fine by me :)

@skjnldsv skjnldsv modified the milestones: Nextcloud 22, Nextcloud 23 Jul 5, 2021
@blizzz blizzz modified the milestones: Nextcloud 23, Nextcloud 24 Nov 30, 2021
@blizzz blizzz modified the milestones: Nextcloud 24, Nextcloud 25 Apr 21, 2022
@blizzz blizzz modified the milestones: Nextcloud 25, Nextcloud 26 Oct 19, 2022
@szaimen

This comment was marked as outdated.

@szaimen szaimen added needs info 0. Needs triage Pending check for reproducibility or if it fits our roadmap and removed 1. to develop Accepted and waiting to be taken care of labels Jan 23, 2023
@szaimen szaimen closed this as completed Mar 6, 2023
@kesselb kesselb reopened this Mar 7, 2023
@kesselb kesselb added 1. to develop Accepted and waiting to be taken care of 25-feedback and removed needs info 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Mar 7, 2023
@kesselb kesselb removed this from the Nextcloud 26 milestone Mar 7, 2023
@grnd-alt grnd-alt linked a pull request Oct 8, 2024 that will close this issue
4 tasks
@grnd-alt grnd-alt self-assigned this Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants