Skip to content

Missing activity for favorites via WebDAV #26393

Closed
@MorrisJobke

Description

  • 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions