From 5b7b8f8dac7d2d1e6fda6526628557ce7233257d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 28 Sep 2016 13:59:50 +0200 Subject: Remove notifications upon user deletion Signed-off-by: Joas Schilling --- lib/private/User/User.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 94ac8c13621..11c0cc8649a 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -214,6 +214,10 @@ class User implements IUser { \OC::$server->getCommentsManager()->deleteReferencesOfActor('users', $this->uid); \OC::$server->getCommentsManager()->deleteReadMarksFromUser($this); + + $notification = \OC::$server->getNotificationManager()->createNotification(); + $notification->setUser($this->uid); + \OC::$server->getNotificationManager()->markProcessed($notification); } if ($this->emitter) { -- cgit v1.2.3 From 4d1acfd4ef7087b8dc7795396c75fd239a6245f4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 29 Sep 2016 15:05:47 +0200 Subject: Only trigger postDelete hooks when the user was deleted... Signed-off-by: Joas Schilling --- lib/private/User/User.php | 6 +++--- tests/lib/User/UserTest.php | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 11c0cc8649a..68787ce60f8 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -218,10 +218,10 @@ class User implements IUser { $notification = \OC::$server->getNotificationManager()->createNotification(); $notification->setUser($this->uid); \OC::$server->getNotificationManager()->markProcessed($notification); - } - if ($this->emitter) { - $this->emitter->emit('\OC\User', 'postDelete', array($this)); + if ($this->emitter) { + $this->emitter->emit('\OC\User', 'postDelete', array($this)); + } } return !($result === false); } diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php index 19afa3642dd..5eee5d60d04 100644 --- a/tests/lib/User/UserTest.php +++ b/tests/lib/User/UserTest.php @@ -435,16 +435,17 @@ class UserTest extends \Test\TestCase { public function dataDeleteHooks() { return [ - [true], - [false], + [true, 2], + [false, 1], ]; } /** * @dataProvider dataDeleteHooks * @param bool $result + * @param int $expectedHooks */ - public function testDeleteHooks($result) { + public function testDeleteHooks($result, $expectedHooks) { $hooksCalled = 0; $test = $this; @@ -521,7 +522,7 @@ class UserTest extends \Test\TestCase { $this->restoreService('CommentsManager'); $this->restoreService('NotificationManager'); - $this->assertEquals(2, $hooksCalled); + $this->assertEquals($expectedHooks, $hooksCalled); } public function testGetCloudId() { -- cgit v1.2.3