-
Notifications
You must be signed in to change notification settings - Fork 56
refactor: Trigger UserFirstTimeLoggedIn instead of manually copying skeleton #1428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,10 +14,12 @@ | |
| use OCP\AppFramework\Http\Attribute\OpenAPI; | ||
| use OCP\AppFramework\Http\DataResponse; | ||
| use OCP\AppFramework\OCSController; | ||
| use OCP\EventDispatcher\IEventDispatcher; | ||
| use OCP\Files\IRootFolder; | ||
| use OCP\Files\NotPermittedException; | ||
| use OCP\IRequest; | ||
| use OCP\IUserManager; | ||
| use OCP\User\Events\UserFirstTimeLoggedInEvent; | ||
|
|
||
| class OcsApiController extends OCSController { | ||
|
|
||
|
|
@@ -26,6 +28,8 @@ | |
| private IRootFolder $root, | ||
| private UserMapper $userMapper, | ||
| private IUserManager $userManager, | ||
| private IEventDispatcher $eventDispatcher, | ||
| private IConfig $config, | ||
|
Check failure on line 32 in lib/Controller/OcsApiController.php
|
||
| ) { | ||
| parent::__construct(Application::APP_ID, $request); | ||
| } | ||
|
|
@@ -65,12 +69,19 @@ | |
| $user->setQuota($quota); | ||
| } | ||
|
|
||
| $userFolder = $this->root->getUserFolder($user->getUID()); | ||
| try { | ||
| // copy skeleton | ||
| \OC_Util::copySkeleton($user->getUID(), $userFolder); | ||
| } catch (NotPermittedException $ex) { | ||
| // read only uses | ||
| // Slighly incorrect, but this event trigger the creation of the file skeleton and | ||
| // the contact book entry. | ||
| $this->eventDispatcher->dispatchTyped(new UserFirstTimeLoggedInEvent($user)); | ||
|
Comment on lines
+72
to
+74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is incorrect, we should not trigger this event unless the user logs in. |
||
|
|
||
| /** Replace with ServerVersion once we depend on NC 31 */ | ||
| if (version_compare($this->config->getSystemValueString('version', '0.0.0'), '34.0.0', '<')) { | ||
|
Check failure on line 77 in lib/Controller/OcsApiController.php
|
||
| $userFolder = $this->root->getUserFolder($user->getUID()); | ||
| try { | ||
| // copy skeleton | ||
| \OC_Util::copySkeleton($user->getUID(), $userFolder); | ||
| } catch (NotPermittedException $ex) { | ||
| // read only uses | ||
| } | ||
| } | ||
|
|
||
| return new DataResponse(['user_id' => $user->getUID()]); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import is missing.
Also you may want to use ServerVersion?