1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @copyright Copyright (c) 2020, Georg Ehrke |
7
|
|
|
* |
8
|
|
|
* @author Georg Ehrke <[email protected]> |
9
|
|
|
* |
10
|
|
|
* @license AGPL-3.0 |
11
|
|
|
* |
12
|
|
|
* This code is free software: you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
14
|
|
|
* as published by the Free Software Foundation. |
15
|
|
|
* |
16
|
|
|
* This program is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
* GNU Affero General Public License for more details. |
20
|
|
|
* |
21
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
23
|
|
|
* |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
namespace OCA\UserStatus\Listener; |
27
|
|
|
|
28
|
|
|
use OCA\UserStatus\Service\StatusService; |
29
|
|
|
use OCP\EventDispatcher\IEventListener; |
30
|
|
|
use OCP\EventDispatcher\Event; |
31
|
|
|
use OCP\User\Events\UserDeletedEvent; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Class UserDeletedListener |
35
|
|
|
* |
36
|
|
|
* @package OCA\UserStatus\Listener |
37
|
|
|
*/ |
38
|
|
|
class UserDeletedListener implements IEventListener { |
39
|
|
|
|
40
|
|
|
/** @var StatusService */ |
41
|
|
|
private $service; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* UserDeletedListener constructor. |
45
|
|
|
* |
46
|
|
|
* @param StatusService $service |
47
|
|
|
*/ |
48
|
|
|
public function __construct(StatusService $service) { |
49
|
|
|
$this->service = $service; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @inheritDoc |
55
|
|
|
*/ |
56
|
|
|
public function handle(Event $event): void { |
57
|
|
|
if (!($event instanceof UserDeletedEvent)) { |
58
|
|
|
// Unrelated |
59
|
|
|
return; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$user = $event->getUser(); |
63
|
|
|
$this->service->removeUserStatus($user->getUID()); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|