Skip to content

Commit

Permalink
fix(admin_audit): Listen to the right events
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <[email protected]>

[skip ci]
  • Loading branch information
come-nc authored and backportbot[bot] committed Oct 3, 2024
1 parent faf9b89 commit 804f349
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
24 changes: 5 additions & 19 deletions apps/admin_audit/lib/Actions/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
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\BeforeNodeWrittenEvent;
use OCP\Files\Events\Node\NodeCopiedEvent;
use OCP\Files\Events\Node\NodeCreatedEvent;
use OCP\Files\Events\Node\NodeDeletedEvent;
use OCP\Files\Events\Node\NodeRenamedEvent;
use OCP\Files\Events\Node\NodeWrittenEvent;
use OCP\Files\InvalidPathException;
Expand All @@ -29,10 +28,9 @@
class Files extends Action {

private array $renamedNodes = [];

/**
* Logs file read actions
*
* @param BeforeNodeReadEvent $event
*/
public function read(BeforeNodeReadEvent $event): void {
try {
Expand All @@ -56,8 +54,6 @@ public function read(BeforeNodeReadEvent $event): void {

/**
* Logs rename actions of files
*
* @param BeforeNodeRenamedEvent $event
*/
public function beforeRename(BeforeNodeRenamedEvent $event): void {
try {
Expand All @@ -73,8 +69,6 @@ public function beforeRename(BeforeNodeRenamedEvent $event): void {

/**
* Logs rename actions of files
*
* @param NodeRenamedEvent $event
*/
public function afterRename(NodeRenamedEvent $event): void {
try {
Expand Down Expand Up @@ -102,8 +96,6 @@ public function afterRename(NodeRenamedEvent $event): void {

/**
* Logs creation of files
*
* @param NodeCreatedEvent $event
*/
public function create(NodeCreatedEvent $event): void {
try {
Expand All @@ -129,8 +121,6 @@ public function create(NodeCreatedEvent $event): void {

/**
* Logs copying of files
*
* @param NodeCopiedEvent $event
*/
public function copy(NodeCopiedEvent $event): void {
try {
Expand All @@ -155,14 +145,12 @@ public function copy(NodeCopiedEvent $event): void {

/**
* Logs writing of files
*
* @param BeforeNodeWrittenEvent $event
*/
public function write(BeforeNodeWrittenEvent $event): void {
public function write(NodeWrittenEvent $event): void {
$node = $event->getNode();
try {
$params = [
'id' => $node instanceof NonExistingFile ? null : $node->getId(),
'id' => $node->getId(),
'path' => mb_substr($node->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
Expand Down Expand Up @@ -208,10 +196,8 @@ public function update(NodeWrittenEvent $event): void {

/**
* Logs deletions of files
*
* @param NodeDeletedEvent $event
*/
public function delete(NodeDeletedEvent $event): void {
public function delete(BeforeNodeDeletedEvent $event): void {
try {
$params = [
'id' => $event->getNode()->getId(),
Expand Down
3 changes: 1 addition & 2 deletions apps/admin_audit/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@
use OCP\Authentication\TwoFactorAuth\TwoFactorProviderChallengePassed;
use OCP\Console\ConsoleEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\Node\BeforeNodeDeletedEvent;
use OCP\Files\Events\Node\BeforeNodeReadEvent;
use OCP\Files\Events\Node\BeforeNodeRenamedEvent;
use OCP\Files\Events\Node\BeforeNodeWrittenEvent;
use OCP\Files\Events\Node\NodeCopiedEvent;
use OCP\Files\Events\Node\NodeCreatedEvent;
use OCP\Files\Events\Node\NodeDeletedEvent;
use OCP\Files\Events\Node\NodeRenamedEvent;
use OCP\Files\Events\Node\NodeWrittenEvent;
use OCP\IConfig;
Expand Down

0 comments on commit 804f349

Please sign in to comment.