From e95e510f53218457c444c57e71aa4bf2469e185d Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Wed, 1 Mar 2023 12:39:16 +0530 Subject: [PATCH 1/2] Do not migrate to snappymail --- lib/AppInfo/Application.php | 2 - .../UserAddedToBetaGroupListener.php | 65 ------------------- 2 files changed, 67 deletions(-) delete mode 100644 lib/Listeners/UserAddedToBetaGroupListener.php diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 87d526f9..74351a24 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -35,7 +35,6 @@ use OCA\EcloudAccounts\Service\LDAPConnectionService; use OCP\User\Events\BeforeUserDeletedEvent; use OCP\User\Events\UserChangedEvent; use OCA\EcloudAccounts\Listeners\UserChangedListener; -use OCA\EcloudAccounts\Listeners\UserAddedToBetaGroupListener; use OCP\Group\Events\UserAddedEvent; use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; use OCA\EcloudAccounts\Listeners\BeforeTemplateRenderedListener; @@ -50,7 +49,6 @@ class Application extends App implements IBootstrap { public function register(IRegistrationContext $context): void { $context->registerEventListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class); $context->registerEventListener(UserChangedEvent::class, UserChangedListener::class); - $context->registerEventListener(UserAddedEvent::class, UserAddedToBetaGroupListener::class); // $context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class); } diff --git a/lib/Listeners/UserAddedToBetaGroupListener.php b/lib/Listeners/UserAddedToBetaGroupListener.php deleted file mode 100644 index 9801632d..00000000 --- a/lib/Listeners/UserAddedToBetaGroupListener.php +++ /dev/null @@ -1,65 +0,0 @@ -config = $config; - $this->logger = $logger; - } - - public function handle(Event $event): void { - if (!($event instanceof UserAddedEvent)) { - return; - } - - $user = $event->getUser(); - $group = $event->getGroup(); - - $betaGroup = $this->config->getSystemValue("beta_group_name"); - - if ($group->getGID() !== $betaGroup) { - return; - } - try { - $this->migrateRainloopData($user); - } catch (Exception $e) { - $errorMessage = 'Error while migrating user rainloop data to snappymail'; - $this->logger->error($errorMessage . ': ' . $e->getMessage()); - } - } - - private function migrateRainloopData(IUser $user): void { - $username = $user->getUID(); - $userDir = substr($username, 0, 2); - $email = $user->getEMailAddress(); - $dataDir = rtrim(trim($this->config->getSystemValue('datadirectory', '')), '\\/'); - $snappyDir = "$dataDir/appdata_snappymail/_data_/_default_/storage/cfg/$userDir/$email/"; - $rainloopDir = "$dataDir/rainloop-storage/_data_/_default_/storage/cfg/$userDir/$email"; - - if (file_exists($snappyDir)) { - $this->logger->debug("$snappyDir already exists"); - return; - } - if (!mkdir($snappyDir, 0755, true)) { - throw new Exception("Unable to mkdir $snappyDir"); - } - if (!shell_exec("cp -avr $rainloopDir/* $snappyDir")) { - throw new Exception("Unable to copy files from $rainloopDir to $snappyDir"); - } - return; - } -} -- GitLab From 1f07b37b9db8e956dcf66c1f8d4b7290ce7da38b Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Wed, 1 Mar 2023 13:43:00 +0530 Subject: [PATCH 2/2] remove unused import --- lib/AppInfo/Application.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 74351a24..3574f538 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -35,7 +35,6 @@ use OCA\EcloudAccounts\Service\LDAPConnectionService; use OCP\User\Events\BeforeUserDeletedEvent; use OCP\User\Events\UserChangedEvent; use OCA\EcloudAccounts\Listeners\UserChangedListener; -use OCP\Group\Events\UserAddedEvent; use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; use OCA\EcloudAccounts\Listeners\BeforeTemplateRenderedListener; -- GitLab