container->get(OwnershipTransferService::class); } catch (QueryException $e) { $this->logger->error('Could not resolve ownership transfer service to import guest user data', [ 'exception' => $e, ]); throw $e; } try { $ownershipTransferService->transfer( $guestUser, $user, '/', null, true, true ); } catch (TransferOwnershipException $e) { $this->logger->error('Could not import guest user data', [ 'exception' => $e, ]); throw $e; } // Update incomming shares $shares = $this->shareManager->getSharedWith($guestUser->getUID(), IShare::TYPE_USER); foreach ($shares as $share) { $share->setSharedWith($user->getUID()); $this->shareManager->updateShare($share); } $notification = $this->notificationManager->createNotification(); $notification ->setApp(Application::APP_ID) ->setSubject('data_migrated_to_system_user') ->setObject('user', $user->getEMailAddress()) ->setDateTime(new \DateTime()) ->setUser($user->getUID()); $this->notificationManager->notify($notification); } /** * @param string $target Target user id */ public function addTransferJob(IUser $author, IUser $source, string $target): void { $transfer = new Transfer(); $transfer->setAuthor($author->getUID()); $transfer->setSource($source->getUID()); $transfer->setTarget($target); $transfer->setStatus(Transfer::STATUS_WAITING); /** @var Transfer $transfer */ $transfer = $this->transferMapper->insert($transfer); $this->jobList->add(TransferJob::class, [ 'id' => $transfer->getId(), ]); } }