diff --git a/apps/admin_audit/lib/Actions/Files.php b/apps/admin_audit/lib/Actions/Files.php index 1a3d9ca4126..3ed0c6bdfb6 100644 --- a/apps/admin_audit/lib/Actions/Files.php +++ b/apps/admin_audit/lib/Actions/Files.php @@ -26,6 +26,8 @@ use Psr\Log\LoggerInterface; * @package OCA\AdminAudit\Actions */ class Files extends Action { + + private array|null $renameParams = null; /** * Logs file read actions * @@ -68,12 +70,7 @@ class Files extends Action { ); return; } - - $this->log( - 'File with id "%s" renamed from "%s"', - $params, - array_keys($params) - ); + $this->renameParams = $params; } /** @@ -84,8 +81,10 @@ class Files extends Action { public function afterRename(NodeRenamedEvent $event): void { try { $target = $event->getTarget(); + $renameParams = $this->renameParams; $params = [ 'newid' => $target->getId(), + 'oldpath' => $renameParams['oldpath'], 'newpath' => mb_substr($target->getInternalPath(), 5), ]; } catch (InvalidPathException|NotFoundException $e) { @@ -96,7 +95,7 @@ class Files extends Action { } $this->log( - 'File with id "%s" renamed to "%s"', + 'File renamed with id "%s" from "%s" to "%s"', $params, array_keys($params) ); diff --git a/apps/admin_audit/lib/AppInfo/Application.php b/apps/admin_audit/lib/AppInfo/Application.php index b40a4fc5929..b8b80841539 100644 --- a/apps/admin_audit/lib/AppInfo/Application.php +++ b/apps/admin_audit/lib/AppInfo/Application.php @@ -181,16 +181,16 @@ class Application extends App implements IBootstrap { ); $eventDispatcher->addListener( - NodeRenamedEvent::class, - function (NodeRenamedEvent $event) use ($fileActions) { - $fileActions->afterRename($event); + BeforeNodeRenamedEvent::class, + function (BeforeNodeRenamedEvent $event) use ($fileActions) { + $fileActions->beforeRename($event); } ); $eventDispatcher->addListener( - BeforeNodeRenamedEvent::class, - function (BeforeNodeRenamedEvent $event) use ($fileActions) { - $fileActions->beforeRename($event); + NodeRenamedEvent::class, + function (NodeRenamedEvent $event) use ($fileActions) { + $fileActions->afterRename($event); } );