diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 87d526f9d73a15ebc4e8915a90373aafc4d32f48..3574f538feb8edcd24943bce57dfec8f9d867f8c 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -35,8 +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 +48,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 9801632d3a6566cbbb3052dd6ad3602689e33953..0000000000000000000000000000000000000000 --- 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; - } -}