fix potentially passing null to events where IUser is expected
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
fd44087530
commit
3a51160221
|
@ -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}',
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue