fix potentially passing null to events where IUser is expected

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2020-10-30 15:38:19 +01:00
parent fd44087530
commit 3a51160221
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
1 changed files with 7 additions and 2 deletions

View File

@ -41,6 +41,7 @@ use OCP\Group\Events\UserRemovedEvent;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IUser;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
@ -153,7 +154,9 @@ class UpdateGroups extends TimedJob {
$groupObject = $this->groupManager->get($group);
foreach (array_diff($knownUsers, $actualUsers) as $removedUser) {
$userObject = $this->userManager->get($removedUser);
$this->dispatcher->dispatchTyped(new UserRemovedEvent($groupObject, $userObject));
if ($userObject instanceof IUser) {
$this->dispatcher->dispatchTyped(new UserRemovedEvent($groupObject, $userObject));
}
$this->logger->info(
'bgJ "updateGroups" {user} removed from {group}',
[
@ -166,7 +169,9 @@ class UpdateGroups extends TimedJob {
}
foreach (array_diff($actualUsers, $knownUsers) as $addedUser) {
$userObject = $this->userManager->get($addedUser);
$this->dispatcher->dispatchTyped(new UserAddedEvent($groupObject, $userObject));
if ($userObject instanceof IUser) {
$this->dispatcher->dispatchTyped(new UserAddedEvent($groupObject, $userObject));
}
$this->logger->info(
'bgJ "updateGroups" {user} added to {group}',
[