migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,137 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2017
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Circles\MountManager;
use OCA\Circles\Tools\Traits\TArrayTools;
use Exception;
use JsonSerializable;
use OC\Files\Mount\MountPoint;
use OC\Files\Mount\MoveableMount;
use OCA\Circles\Exceptions\MountPointConstructionException;
use OCA\Circles\Model\Mount;
use OCP\Files\Storage\IStorageFactory;
/**
* Class CircleMount
*
* @package OCA\Circles\MountManager
*/
class CircleMount extends MountPoint implements MoveableMount, JsonSerializable {
use TArrayTools;
/** @var Mount */
private $mount;
/** @var string */
private $storageClass;
/**
* CircleMount constructor.
*
* @param Mount $mount
* @param string $storage
* @param IStorageFactory|null $loader
*
* @throws MountPointConstructionException
*/
public function __construct(
Mount $mount,
string $storage,
?IStorageFactory $loader = null
) {
try {
parent::__construct(
$storage,
$mount->getMountPoint(false),
$mount->toMount(),
$loader
);
} catch (Exception $e) {
throw new MountPointConstructionException();
}
$this->mount = $mount;
$this->storageClass = $storage;
}
/**
* Move the mount point to $target
*
* @param string $target the target mount point
*
* @return bool
*/
public function moveMount($target) {
$result = $this->mount->getMountManager()->renameShare($this->gsShareId, $target);
$this->setMountPoint($target);
return $result;
}
/**
* Remove the mount points
*
* @return mixed
* @return bool
*/
public function removeMount() {
return $this->mount->getMountManager()->unshare($this->gsShareId);
}
/**
* Get the type of mount point, used to distinguish things like shares and external storages
* in the web interface
*
* @return string
*/
public function getMountType() {
return 'shared';
}
public function getInitiator() {
}
/**
* @return array
*/
public function jsonSerialize(): array {
return [
'mount' => $this->mount,
'storage' => $this->storageClass
];
}
}
@@ -0,0 +1,128 @@
<?php
declare(strict_types=1);
/*
* Circles - Bring cloud-users closer together.
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2017
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Circles\MountManager;
use OCA\Circles\Db\GSSharesRequest;
use OCA\Circles\Model\GlobalScale\GSShareMountpoint;
use OCP\Share\Exceptions\ShareNotFound;
/**
* Class CircleMountManager
* @deprecated
* @package OCA\Circles\MountManager
*/
class CircleMountManager {
/** @var string */
private $userId;
/** @var GSSharesRequest */
private $gsSharesRequest;
/**
* MountManager constructor.
*
* @param string $userId
* @param GSSharesRequest $gsSharesRequest
*/
public function __construct($userId, GSSharesRequest $gsSharesRequest) {
$this->userId = $userId;
$this->gsSharesRequest = $gsSharesRequest;
}
/**
* @param int $gsShareId
* @param string $target
*
* @return bool
*/
public function renameShare(int $gsShareId, string $target) {
try {
if ($target !== '-') {
$target = $this->stripPath($target);
$this->gsSharesRequest->getShareMountPointByPath($this->userId, $target);
return false;
}
} catch (ShareNotFound $e) {
}
$mountPoint = new GSShareMountpoint($gsShareId, $this->userId, $target);
try {
$this->gsSharesRequest->getShareMountPointById($gsShareId, $this->userId);
$this->gsSharesRequest->updateShareMountPoint($mountPoint);
} catch (ShareNotFound $e) {
$this->gsSharesRequest->generateShareMountPoint($mountPoint);
}
return true;
}
// TODO: implement !
public function getMountManager() {
return $this;
}
// TODO: implement !
public function removeShare($mountPoint) {
}
// TODO: implement !
public function removeMount($mountPoint) {
}
/**
* @param int $gsShareId
*
* @return bool
*/
public function unshare(int $gsShareId) {
return $this->renameShare($gsShareId, '-');
}
/**
* remove '/user/files' from the path and trailing slashes
*
* @param string $path
*
* @return string
*/
protected function stripPath($path) {
$prefix = '/' . $this->userId . '/files';
return rtrim(substr($path, strlen($prefix)), '/');
}
}
@@ -0,0 +1,241 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2021
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Circles\MountManager;
use OCA\Circles\Tools\Traits\TArrayTools;
use Exception;
use OCA\Circles\Db\MountRequest;
use OCA\Circles\Exceptions\FederatedUserException;
use OCA\Circles\Exceptions\FederatedUserNotFoundException;
use OCA\Circles\Exceptions\InitiatorNotFoundException;
use OCA\Circles\Exceptions\InvalidIdException;
use OCA\Circles\Exceptions\MountPointConstructionException;
use OCA\Circles\Exceptions\RequestBuilderException;
use OCA\Circles\Exceptions\SingleCircleNotFoundException;
use OCA\Circles\Model\Member;
use OCA\Circles\Model\Mount;
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\FederatedUserService;
use OCA\Files_Sharing\External\Storage as ExternalStorage;
use OCP\Federation\ICloudIdManager;
use OCP\Files\Config\IMountProvider;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage\IStorageFactory;
use OCP\Http\Client\IClientService;
use OCP\IUser;
/**
* Class CircleMountProvider
*
* @package OCA\Circles\MountManager
*/
class CircleMountProvider implements IMountProvider {
use TArrayTools;
// const LOCAL_STORAGE = ::class;
public const EXTERNAL_STORAGE = ExternalStorage::class;
/** @var IClientService */
private $clientService;
/** @var CircleMountManager */
private $circleMountManager;
/** @var ICloudIdManager */
private $cloudIdManager;
/** @var MountRequest */
private $mountRequest;
/** @var FederatedUserService */
private $federatedUserService;
/** @var ConfigService */
private $configService;
/**
* MountProvider constructor.
*
* @param IClientService $clientService
* @param CircleMountManager $circleMountManager
* @param ICloudIdManager $cloudIdManager
* @param MountRequest $mountRequest
* @param FederatedUserService $federatedUserService
* @param ConfigService $configService
*/
public function __construct(
IClientService $clientService,
CircleMountManager $circleMountManager,
ICloudIdManager $cloudIdManager,
MountRequest $mountRequest,
FederatedUserService $federatedUserService,
ConfigService $configService
) {
$this->clientService = $clientService;
$this->circleMountManager = $circleMountManager;
$this->cloudIdManager = $cloudIdManager;
$this->mountRequest = $mountRequest;
$this->federatedUserService = $federatedUserService;
$this->configService = $configService;
}
/**
* @param IUser $user
* @param IStorageFactory $loader
*
* @return IMountPoint[]
* @throws RequestBuilderException
* @throws FederatedUserException
* @throws FederatedUserNotFoundException
* @throws InvalidIdException
* @throws SingleCircleNotFoundException
*/
public function getMountsForUser(IUser $user, IStorageFactory $loader): array {
$federatedUser = $this->federatedUserService->getLocalFederatedUser($user->getUID());
$items = $this->mountRequest->getForUser($federatedUser);
$mounts = [];
foreach ($items as $item) {
try {
// if ($share->getMountPoint() !== '-') {
// $this->fixDuplicateFile($user->getUID(), $gss.share);
$mounts[] = $this->generateCircleMount($item, $loader);
// }
} catch (Exception $e) {
}
}
return $mounts;
}
/**
* @param Mount $mount
* @param IStorageFactory $storageFactory
*
* @return CircleMount
* @throws InitiatorNotFoundException
* @throws MountPointConstructionException
*/
public function generateCircleMount(Mount $mount, IStorageFactory $storageFactory): CircleMount {
$initiator = $mount->getInitiator();
// TODO: right now, limited to Local Nextcloud User
if ($initiator->getInheritedBy()->getUserType() !== Member::TYPE_USER
|| !$this->configService->isLocalInstance($initiator->getInheritedBy()->getInstance())) {
throw new InitiatorNotFoundException();
}
$mount->setCloudIdManager($this->cloudIdManager)
->setHttpClientService($this->clientService)
// ->setStorage(self::EXTERNAL_STORAGE)
->setMountManager($this->circleMountManager);
return new CircleMount(
$mount,
self::EXTERNAL_STORAGE,
$storageFactory
);
}
/**
* @param int $gsShareId
* @param string $target
*
* @return bool
*/
public function renameShare(int $gsShareId, string $target) {
// try {
// if ($target !== '-') {
// $target = $this->stripPath($target);
// $this->gsSharesRequest->getShareMountPointByPath($this->userId, $target);
//
// return false;
// }
// } catch (ShareNotFound $e) {
// }
//
// $mountPoint = new GSShareMountpoint($gsShareId, $this->userId, $target);
// try {
// $this->gsSharesRequest->getShareMountPointById($gsShareId, $this->userId);
// $this->gsSharesRequest->updateShareMountPoint($mountPoint);
// } catch (ShareNotFound $e) {
// $this->gsSharesRequest->generateShareMountPoint($mountPoint);
// }
return true;
}
// TODO: implement !
public function getMountManager() {
return $this;
}
// TODO: implement !
public function removeShare($mountPoint) {
}
// TODO: implement !
public function removeMount($mountPoint) {
}
/**
* @param int $gsShareId
*
* @return bool
*/
public function unshare(int $gsShareId) {
return $this->renameShare($gsShareId, '-');
}
/**
* remove '/user/files' from the path and trailing slashes
*
* @param string $path
*
* @return string
*/
protected function stripPath($path) {
return $path;
// $prefix = '/' . $this->userId . '/files';
//
// return rtrim(substr($path, strlen($prefix)), '/');
}
}