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
+86
View File
@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @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 OC\Core\Db;
use OCP\AppFramework\Db\Entity;
/**
* @method int getTimestamp()
* @method void setTimestamp(int $timestamp)
* @method int getStarted()
* @method void setStarted(int $started)
* @method string getPollToken()
* @method void setPollToken(string $token)
* @method string getLoginToken()
* @method void setLoginToken(string $token)
* @method string getPublicKey()
* @method void setPublicKey(string $key)
* @method string getPrivateKey()
* @method void setPrivateKey(string $key)
* @method string getClientName()
* @method void setClientName(string $clientName)
* @method string getLoginName()
* @method void setLoginName(string $loginName)
* @method string getServer()
* @method void setServer(string $server)
* @method string getAppPassword()
* @method void setAppPassword(string $appPassword)
*/
class LoginFlowV2 extends Entity {
/** @var int */
protected $timestamp;
/** @var int */
protected $started;
/** @var string */
protected $pollToken;
/** @var string */
protected $loginToken;
/** @var string */
protected $publicKey;
/** @var string */
protected $privateKey;
/** @var string */
protected $clientName;
/** @var string */
protected $loginName;
/** @var string */
protected $server;
/** @var string */
protected $appPassword;
public function __construct() {
$this->addType('timestamp', 'int');
$this->addType('started', 'int');
$this->addType('pollToken', 'string');
$this->addType('loginToken', 'string');
$this->addType('publicKey', 'string');
$this->addType('privateKey', 'string');
$this->addType('clientName', 'string');
$this->addType('loginName', 'string');
$this->addType('server', 'string');
$this->addType('appPassword', 'string');
}
}
+107
View File
@@ -0,0 +1,107 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @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 OC\Core\Db;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\QBMapper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IDBConnection;
/**
* @template-extends QBMapper<LoginFlowV2>
*/
class LoginFlowV2Mapper extends QBMapper {
private const lifetime = 1200;
public function __construct(
IDBConnection $db,
private ITimeFactory $timeFactory,
) {
parent::__construct(
$db,
'login_flow_v2',
LoginFlowV2::class,
);
}
/**
* @param string $pollToken
* @return LoginFlowV2
* @throws DoesNotExistException
*/
public function getByPollToken(string $pollToken): LoginFlowV2 {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where(
$qb->expr()->eq('poll_token', $qb->createNamedParameter($pollToken))
);
$entity = $this->findEntity($qb);
return $this->validateTimestamp($entity);
}
/**
* @param string $loginToken
* @return LoginFlowV2
* @throws DoesNotExistException
*/
public function getByLoginToken(string $loginToken): LoginFlowV2 {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where(
$qb->expr()->eq('login_token', $qb->createNamedParameter($loginToken))
);
$entity = $this->findEntity($qb);
return $this->validateTimestamp($entity);
}
public function cleanup(): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
->where(
$qb->expr()->lt('timestamp', $qb->createNamedParameter($this->timeFactory->getTime() - self::lifetime))
);
$qb->execute();
}
/**
* @param LoginFlowV2 $flowV2
* @return LoginFlowV2
* @throws DoesNotExistException
*/
private function validateTimestamp(LoginFlowV2 $flowV2): LoginFlowV2 {
if ($flowV2->getTimestamp() < ($this->timeFactory->getTime() - self::lifetime)) {
$this->delete($flowV2);
throw new DoesNotExistException('Token expired');
}
return $flowV2;
}
}
+123
View File
@@ -0,0 +1,123 @@
<?php
declare(strict_types=1);
/**
* @copyright 2021 Christopher Ng <chrng8@gmail.com>
*
* @author Christopher Ng <chrng8@gmail.com>
*
* @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 OC\Core\Db;
use \JsonSerializable;
use OCP\AppFramework\Db\Entity;
use OCP\Profile\ParameterDoesNotExistException;
use function json_decode;
use function json_encode;
/**
* @method string getUserId()
* @method void setUserId(string $userId)
* @method string getConfig()
* @method void setConfig(string $config)
*/
class ProfileConfig extends Entity implements JsonSerializable {
/** @var string */
protected $userId;
/** @var string */
protected $config;
public function __construct() {
$this->addType('userId', 'string');
$this->addType('config', 'string');
}
/**
* Returns the config in an associative array
*/
public function getConfigArray(): array {
return json_decode($this->config, true);
}
/**
* Set the config
*/
public function setConfigArray(array $config): void {
$this->setConfig(json_encode($config));
}
/**
* Returns the visibility map in an associative array
*/
public function getVisibilityMap(): array {
$config = $this->getConfigArray();
$visibilityMap = [];
foreach ($config as $paramId => $paramConfig) {
$visibilityMap[$paramId] = $paramConfig['visibility'];
}
return $visibilityMap;
}
/**
* Set the visibility map
*/
public function setVisibilityMap(array $visibilityMap): void {
$config = $this->getConfigArray();
foreach ($visibilityMap as $paramId => $visibility) {
$config[$paramId] = array_merge(
$config[$paramId] ?: [],
['visibility' => $visibility],
);
}
$this->setConfigArray($config);
}
/**
* Returns the visibility of the parameter
*
* @throws ParameterDoesNotExistException
*/
public function getVisibility(string $paramId): string {
$visibilityMap = $this->getVisibilityMap();
if (isset($visibilityMap[$paramId])) {
return $visibilityMap[$paramId];
}
throw new ParameterDoesNotExistException($paramId);
}
/**
* Set the visibility of the parameter
*/
public function setVisibility(string $paramId, string $visibility): void {
$visibilityMap = $this->getVisibilityMap();
$visibilityMap[$paramId] = $visibility;
$this->setVisibilityMap($visibilityMap);
}
public function jsonSerialize(): array {
return [
'userId' => $this->userId,
'config' => $this->getConfigArray(),
];
}
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* @copyright 2021 Christopher Ng <chrng8@gmail.com>
*
* @author Christopher Ng <chrng8@gmail.com>
*
* @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 OC\Core\Db;
use OCP\AppFramework\Db\QBMapper;
use OCP\IDBConnection;
/**
* @template-extends QBMapper<ProfileConfig>
*/
class ProfileConfigMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'profile_config', ProfileConfig::class);
}
public function get(string $userId): ProfileConfig {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
return $this->findEntity($qb);
}
public function getArray(string $userId): array {
return $this->get($userId)->getConfigArray();
}
}