-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48612 from nextcloud/fix/activity-log-for-favorit…
…es-in-dav add activity logging for favorites in dav
- Loading branch information
Showing
14 changed files
with
164 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
namespace OCA\Files\Listener; | ||
|
||
use OCA\Files\Activity\FavoriteProvider; | ||
use OCP\Activity\IManager as IActivityManager; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\Files\Events\NodeAddedToFavorite; | ||
|
||
/** @template-implements IEventListener<NodeAddedToFavorite> */ | ||
class NodeAddedToFavoriteListener implements IEventListener { | ||
public function __construct( | ||
private IActivityManager $activityManager, | ||
) { | ||
} | ||
public function handle(Event $event):void { | ||
if (!($event instanceof NodeAddedToFavorite)) { | ||
return; | ||
} | ||
$activityEvent = $this->activityManager->generateEvent(); | ||
try { | ||
$activityEvent->setApp('files') | ||
->setObject('files', $event->getFileId(), $event->getPath()) | ||
->setType('favorite') | ||
->setAuthor($event->getUser()->getUID()) | ||
->setAffectedUser($event->getUser()->getUID()) | ||
->setTimestamp(time()) | ||
->setSubject( | ||
FavoriteProvider::SUBJECT_ADDED, | ||
['id' => $event->getFileId(), 'path' => $event->getPath()] | ||
); | ||
$this->activityManager->publish($activityEvent); | ||
} catch (\InvalidArgumentException $e) { | ||
} catch (\BadMethodCallException $e) { | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
apps/files/lib/Listener/NodeRemovedFromFavoriteListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
namespace OCA\Files\Listener; | ||
|
||
use OCA\Files\Activity\FavoriteProvider; | ||
use OCP\Activity\IManager as IActivityManager; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\Files\Events\NodeRemovedFromFavorite; | ||
|
||
/** @template-implements IEventListener<NodeRemovedFromFavorite> */ | ||
class NodeRemovedFromFavoriteListener implements IEventListener { | ||
public function __construct( | ||
private IActivityManager $activityManager, | ||
) { | ||
} | ||
public function handle(Event $event):void { | ||
if (!($event instanceof NodeRemovedFromFavorite)) { | ||
return; | ||
} | ||
$activityEvent = $this->activityManager->generateEvent(); | ||
try { | ||
$activityEvent->setApp('files') | ||
->setObject('files', $event->getFileId(), $event->getPath()) | ||
->setType('favorite') | ||
->setAuthor($event->getUser()->getUID()) | ||
->setAffectedUser($event->getUser()->getUID()) | ||
->setTimestamp(time()) | ||
->setSubject( | ||
FavoriteProvider::SUBJECT_REMOVED, | ||
['id' => $event->getFileId(), 'path' => $event->getPath()] | ||
); | ||
$this->activityManager->publish($activityEvent); | ||
} catch (\InvalidArgumentException $e) { | ||
} catch (\BadMethodCallException $e) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.