aboutsummaryrefslogtreecommitdiffstats
path: root/apps/admin_audit
diff options
context:
space:
mode:
authoryemkareems <yemkareems@gmail.com>2024-06-13 17:35:15 +0530
committeryemkareems <yemkareems@gmail.com>2024-06-20 10:54:45 +0530
commit953358fdc89aaffcd54bec90a3c02d989ebe50cd (patch)
treeab246b5781a6364c291ebf881d116a3d9fdf3f03 /apps/admin_audit
parent3e355c4db12caad198abde5e9a9d67afc22f3034 (diff)
downloadnextcloud-server-953358fdc89aaffcd54bec90a3c02d989ebe50cd.tar.gz
nextcloud-server-953358fdc89aaffcd54bec90a3c02d989ebe50cd.zip
fix: rename params old path passed from before rename to after rename to have one log for rename event
Signed-off-by: yemkareems <yemkareems@gmail.com>
Diffstat (limited to 'apps/admin_audit')
-rw-r--r--apps/admin_audit/lib/Actions/Files.php13
-rw-r--r--apps/admin_audit/lib/AppInfo/Application.php12
2 files changed, 12 insertions, 13 deletions
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);
}
);