diff options
Diffstat (limited to 'apps/admin_audit/lib/Actions')
-rw-r--r-- | apps/admin_audit/lib/Actions/Action.php | 7 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/Files.php | 37 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/Versions.php | 10 |
3 files changed, 11 insertions, 43 deletions
diff --git a/apps/admin_audit/lib/Actions/Action.php b/apps/admin_audit/lib/Actions/Action.php index 2566025a8ce..acd415d82ea 100644 --- a/apps/admin_audit/lib/Actions/Action.php +++ b/apps/admin_audit/lib/Actions/Action.php @@ -37,11 +37,8 @@ class Action { ); } else { $this->logger->critical( - sprintf( - '$params["' . $element . '"] was missing. Transferred value: %s', - print_r($params, true) - ), - ['app' => 'admin_audit'] + '$params["' . $element . '"] was missing. Transferred value: {params}', + ['app' => 'admin_audit', 'params' => $params] ); } return; diff --git a/apps/admin_audit/lib/Actions/Files.php b/apps/admin_audit/lib/Actions/Files.php index 3993f1a76ee..7be4a7cd581 100644 --- a/apps/admin_audit/lib/Actions/Files.php +++ b/apps/admin_audit/lib/Actions/Files.php @@ -10,7 +10,6 @@ namespace OCA\AdminAudit\Actions; use OC\Files\Node\NonExistingFile; use OCP\Files\Events\Node\BeforeNodeDeletedEvent; use OCP\Files\Events\Node\BeforeNodeReadEvent; -use OCP\Files\Events\Node\BeforeNodeRenamedEvent; use OCP\Files\Events\Node\NodeCopiedEvent; use OCP\Files\Events\Node\NodeCreatedEvent; use OCP\Files\Events\Node\NodeRenamedEvent; @@ -26,9 +25,6 @@ use Psr\Log\LoggerInterface; * @package OCA\AdminAudit\Actions */ class Files extends Action { - - private array $renamedNodes = []; - /** * Logs file read actions */ @@ -37,7 +33,7 @@ class Files extends Action { $node = $event->getNode(); $params = [ 'id' => $node instanceof NonExistingFile ? null : $node->getId(), - 'path' => mb_substr($node->getInternalPath(), 5), + 'path' => $node->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( @@ -55,29 +51,14 @@ class Files extends Action { /** * Logs rename actions of files */ - public function beforeRename(BeforeNodeRenamedEvent $event): void { - try { - $source = $event->getSource(); - $this->renamedNodes[$source->getId()] = $source; - } catch (InvalidPathException|NotFoundException $e) { - Server::get(LoggerInterface::class)->error( - 'Exception thrown in file rename: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e] - ); - return; - } - } - - /** - * Logs rename actions of files - */ public function afterRename(NodeRenamedEvent $event): void { try { $target = $event->getTarget(); - $originalSource = $this->renamedNodes[$target->getId()]; + $source = $event->getSource(); $params = [ 'newid' => $target->getId(), - 'oldpath' => mb_substr($originalSource->getInternalPath(), 5), - 'newpath' => mb_substr($target->getInternalPath(), 5), + 'oldpath' => $source->getPath(), + 'newpath' => $target->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( @@ -101,7 +82,7 @@ class Files extends Action { try { $params = [ 'id' => $event->getNode()->getId(), - 'path' => mb_substr($event->getNode()->getInternalPath(), 5), + 'path' => $event->getNode()->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( @@ -127,8 +108,8 @@ class Files extends Action { $params = [ 'oldid' => $event->getSource()->getId(), 'newid' => $event->getTarget()->getId(), - 'oldpath' => mb_substr($event->getSource()->getInternalPath(), 5), - 'newpath' => mb_substr($event->getTarget()->getInternalPath(), 5), + 'oldpath' => $event->getSource()->getPath(), + 'newpath' => $event->getTarget()->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( @@ -151,7 +132,7 @@ class Files extends Action { try { $params = [ 'id' => $node->getId(), - 'path' => mb_substr($node->getInternalPath(), 5), + 'path' => $node->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( @@ -177,7 +158,7 @@ class Files extends Action { try { $params = [ 'id' => $event->getNode()->getId(), - 'path' => mb_substr($event->getNode()->getInternalPath(), 5), + 'path' => $event->getNode()->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( diff --git a/apps/admin_audit/lib/Actions/Versions.php b/apps/admin_audit/lib/Actions/Versions.php index c856c994d3f..b3fdefd011d 100644 --- a/apps/admin_audit/lib/Actions/Versions.php +++ b/apps/admin_audit/lib/Actions/Versions.php @@ -8,16 +8,6 @@ declare(strict_types=1); namespace OCA\AdminAudit\Actions; class Versions extends Action { - public function rollback(array $params): void { - $this->log('Version "%s" of "%s" was restored.', - [ - 'version' => $params['revision'], - 'path' => $params['path'] - ], - ['version', 'path'] - ); - } - public function delete(array $params): void { $this->log('Version "%s" was deleted.', ['path' => $params['path']], |