]> source.dussan.org Git - nextcloud-server.git/commitdiff
switch to typed event for LDAPs user added to group case 22771/head
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 10 Sep 2020 10:57:10 +0000 (12:57 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 10 Sep 2020 10:57:10 +0000 (12:57 +0200)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/user_ldap/lib/Jobs/UpdateGroups.php

index a517216113e18ecf353d53907adad4dd767fb10b..8cbac261e9fb92da8b2f217c6cf2a577034c63d9 100644 (file)
@@ -44,6 +44,7 @@ use OCA\User_LDAP\Mapping\GroupMapping;
 use OCA\User_LDAP\Mapping\UserMapping;
 use OCA\User_LDAP\User\Manager;
 use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Group\Events\UserAddedEvent;
 use OCP\Group\Events\UserRemovedEvent;
 use OCP\ILogger;
 
@@ -95,6 +96,7 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob {
         * @param string[] $groups
         */
        private static function handleKnownGroups($groups) {
+               /** @var IEventDispatcher $dispatcher */
                $dispatcher = \OC::$server->query(IEventDispatcher::class);
                $groupManager = \OC::$server->getGroupManager();
                $userManager = \OC::$server->getUserManager();
@@ -121,7 +123,8 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob {
                                $hasChanged = true;
                        }
                        foreach (array_diff($actualUsers, $knownUsers) as $addedUser) {
-                               \OCP\Util::emitHook('OC_User', 'post_addToGroup', ['uid' => $addedUser, 'gid' => $group]);
+                               $userObject = $userManager->get($addedUser);
+                               $dispatcher->dispatchTyped(new UserAddedEvent($groupObject, $userObject));
                                \OCP\Util::writeLog('user_ldap',
                                'bgJ "updateGroups" – "'.$addedUser.'" added to "'.$group.'".',
                                        ILogger::INFO);