Trouble getting file hook callbacks to trigger

Hi all,

I’m at my wits end… I’m trying to catch a number of file actions by registering hooks. From looking at a number of other apps’ sources I think this should work… but it doesn’t.

Here’s the code:
app.php

<?php
namespace OCA\SlackNotify\AppInfo;

use OCP\AppFramework\App;
use OCP\IL10N;
use OCP\Util;

$app = new App('slacknotify');
$container = $app->getContainer();
$container->query('OCP\INavigationManager')->add(function () use ($container) {
    $urlGenerator = $container->query('OCP\IURLGenerator');
    $l10n = $container->query('OCP\IL10N');
    return [
        'id' => 'slacknotify',
        'order' => 10,
        'href' => $urlGenerator->linkToRoute('slacknotify.page.index'),
        'icon' => $urlGenerator->imagePath('slacknotify', 'app.svg'),
        'name' => $l10n->t('Slack Notify'),
    ];
});

$container->registerService('Logger', function($c) {
    return $c->query('ServerContainer')->getLogger();
});

$container->registerService('FileHooks', function($c) {
    return new FileHooks(
        $c->query('ServerContainer')->getRootFolder(),
        $c->query('Logger'),
        "SlackNotify"
    );
});

$filehooks = $container->query('FileHooks');
$filehooks->registerPostDelete();
$filehooks->registerPostRename();

FileHooks.php

<?php
namespace OCA\SlackNotify\AppInfo;

use OCP\AppFramework\App;
use OCP\Util;
use OCP\ILogger;

class FileHooks {

	private $rootFolder;
	private $logger;
	private	$appName;

	public function __construct($rootFolder, ILogger $logger, $appName) {
		$this->rootFolder = $rootFolder;
		$this->logger = $logger;
		$this->appName = $appName;
	}

	public function log($message) {
		$this->logger->debug($message, array('app' => $this->appName));
	}

	public function registerPostDelete() {
		$reference = $this;

		$callback = function(\OCP\Files\Node $node) use($reference){
			$reference->log("SlackNotify: PostDelete");  // this is not being shown
			// $reference->log("SlackNotify: ".($node->GetName()));
		};

		$this->log("Registered postDelete");  // this is being shown in the log

		$this->rootFolder->listen('\OC\Files', 'postDelete', $callback);
	}

	public function registerPostRename() {
		$reference = $this;

		$callback = function(\OCP\Files\Node $source, \OCP\Files\Node $target) use($reference){
			$reference->log("SlackNotify: postRename");  // this is not being shown
			// $reference->log("SlackNotify: ".($source->GetName())); 
			// $reference->log("SlackNotify: ".($target->GetName())); 
		};

		$this->log("Registered preRename");  // this is being shown in the log

		$this->rootFolder->listen('\OC\Files', 'preRename', $callback);
	}
}

So my initial log call when I register the hooks get triggered, but the actual callback is never called. Or at least I can’t see anything happen. Any ideas what could be going on here?

Thanks! (PS this is NextCloud 11.01)