|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (c) 2016, Roeland Jago Douma <[email protected]> |
|
5
|
|
|
* @copyright Copyright (c) 2017-2021 Matias De lellis <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @author Roeland Jago Douma <[email protected]> |
|
8
|
|
|
* @author Matias De lellis <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* @license GNU AGPL version 3 or any later version |
|
11
|
|
|
* |
|
12
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
14
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
15
|
|
|
* License, or (at your option) any later version. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, |
|
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20
|
|
|
* GNU Affero General Public License for more details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
23
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24
|
|
|
* |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace OCA\FaceRecognition\Hooks; |
|
28
|
|
|
|
|
29
|
|
|
use OCP\ILogger; |
|
30
|
|
|
use OCP\IUserManager; |
|
31
|
|
|
|
|
32
|
|
|
use OCA\FaceRecognition\Service\FaceManagementService; |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
class UserHooks { |
|
36
|
|
|
|
|
37
|
|
|
/** @var ILogger Logger */ |
|
38
|
|
|
private $logger; |
|
39
|
|
|
|
|
40
|
|
|
/** @var IUserManager */ |
|
41
|
|
|
private $userManager; |
|
42
|
|
|
|
|
43
|
|
|
/** @var FaceManagementService */ |
|
44
|
|
|
private $faceManagementService; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Watcher constructor. |
|
48
|
|
|
* |
|
49
|
|
|
* @param ILogger $logger |
|
50
|
|
|
* @param IUserManager $userManager |
|
51
|
|
|
* @param FaceManagementService $faceManagementService |
|
52
|
|
|
*/ |
|
53
|
|
|
public function __construct(ILogger $logger, |
|
54
|
|
|
IUserManager $userManager, |
|
55
|
|
|
FaceManagementService $faceManagementService) |
|
56
|
|
|
{ |
|
57
|
|
|
$this->logger = $logger; |
|
58
|
|
|
$this->userManager = $userManager; |
|
59
|
|
|
$this->faceManagementService = $faceManagementService; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
28 |
|
public function register() { |
|
63
|
|
|
// Watch for user deletion, so we clean up user data, after user gets deleted |
|
64
|
|
|
$this->userManager->listen('\OC\User', 'postDelete', function (\OC\User\User $user) { |
|
|
|
|
|
|
65
|
28 |
|
$this->postUserDelete($user); |
|
66
|
28 |
|
}); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* A user has been deleted. Cleanup everything from this user. |
|
71
|
|
|
* |
|
72
|
|
|
* @param \OC\User\User $user Deleted user |
|
73
|
|
|
*/ |
|
74
|
28 |
|
public function postUserDelete(\OC\User\User $user) { |
|
75
|
28 |
|
$userId = $user->getUid(); |
|
76
|
28 |
|
$this->faceManagementService->resetAllForUser($userId); |
|
77
|
28 |
|
$this->logger->info("Removed all face recognition data for deleted user " . $userId); |
|
|
|
|
|
|
78
|
28 |
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths