Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2019-10-24 11:55:05 +0300
committerJoas Schilling <coding@schilljs.com>2019-10-24 15:24:42 +0300
commit162717df1d888c1ba774428b86e3875a646da4f4 (patch)
treef2a89ac6a5b5a7e517bdca71ddd8dd86c709c8d7 /lib
parent3182c5a36ba85799c2cbd9a53b7cdec5b28f3225 (diff)
Delete notifications on user deletion
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/AppInfo/Application.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 3582013..6a9de02 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -24,6 +24,7 @@ namespace OCA\Notifications\AppInfo;
use OC\Authentication\Token\IProvider;
use OCA\Notifications\App;
use OCA\Notifications\Capabilities;
+use OCA\Notifications\Handler;
use OCA\Notifications\Notifier\AdminNotifications;
use OCP\AppFramework\IAppContainer;
use OCP\Util;
@@ -45,6 +46,7 @@ class Application extends \OCP\AppFramework\App {
$this->registerNotificationApp();
$this->registerAdminNotifications();
$this->registerUserInterface();
+ $this->registerUserDeleteHook();
}
protected function registerNotificationApp(): void {
@@ -74,4 +76,14 @@ class Application extends \OCP\AppFramework\App {
Util::addStyle('notifications', 'styles');
}
}
+
+ protected function registerUserDeleteHook(): void {
+ Util::connectHook('OC_User', 'post_deleteUser', $this, 'deleteUser');
+ }
+
+ public function deleteUser(array $params): void {
+ /** @var Handler $handler */
+ $handler = $this->getContainer()->query(Handler::class);
+ $handler->deleteByUser($params['uid']);
+ }
}