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,75 @@
<?php
/**
* 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\Search;
use OCA\Circles\ISearch;
use OCA\Circles\Model\DeprecatedMember;
use OCA\Circles\Model\SearchResult;
use OCA\Circles\Service\MiscService;
class Contacts implements ISearch {
/**
* {@inheritdoc}
*/
public function search($needle): array {
$result = [];
$contactManager = \OC::$server->getContactsManager();
// Add 'ADR' to search also in the address
$contacts = $contactManager->search($needle, ['FN', 'ORG', 'EMAIL']);
foreach ($contacts as $contact) {
if (($contact['isLocalSystemBook'] ?? false) === true) {
continue;
}
$data = $this->generateDataArray($contact);
$result[] = new SearchResult($contact['UID'], DeprecatedMember::TYPE_CONTACT, '', $data);
}
return $result;
}
/**
* @param array $contact
*
* @return array
*/
private function generateDataArray($contact) {
$data = [
'display' => '',
'email' => '',
'organization' => ''
];
$data['display'] = $data['email'] = MiscService::get($contact, 'EMAIL');
$data['display'] = MiscService::get($contact, 'FN', $data['display']);
$data['organization'] = MiscService::get($contact, 'ORG');
return $data;
}
}
@@ -0,0 +1,60 @@
<?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\Search;
use OCA\Circles\Db\MemberRequest;
use OCA\Circles\ISearch;
/**
* Class FederatedUsers
*
* @package OCA\Circles\Search
*/
class FederatedUsers implements ISearch {
private MemberRequest $memberRequest;
/**
* LocalUsers constructor.
*
* @param MemberRequest $memberRequest
*/
public function __construct(MemberRequest $memberRequest) {
$this->memberRequest = $memberRequest;
}
/**
* {@inheritdoc}
*/
public function search(string $needle): array {
return $this->memberRequest->searchFederatedUsers($needle);
}
}
@@ -0,0 +1,115 @@
<?php
/**
* 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\Search;
use OCA\Circles\Tools\Exceptions\RequestNetworkException;
use OCA\Circles\Tools\Exceptions\RequestResultNotJsonException;
use OCA\Circles\Tools\Model\NCRequest;
use OCA\Circles\Tools\Model\Request;
use OCA\Circles\Tools\Traits\TNCRequest;
use OCA\Circles\Tools\Traits\TArrayTools;
use OCA\Circles\Exceptions\GSStatusException;
use OCA\Circles\ISearch;
use OCA\Circles\Model\DeprecatedMember;
use OCA\Circles\Model\SearchResult;
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\MiscService;
/**
* Class GlobalScaleUsers
*
* @package OCA\Circles\Search
*/
class GlobalScaleUsers implements ISearch {
use TNCRequest;
use TArrayTools;
/** @var ConfigService */
private $configService;
/** @var MiscService */
private $miscService;
/**
* GlobalScaleUsers constructor.
*
* @param ConfigService $configService
* @param MiscService $miscService
*/
public function __construct(ConfigService $configService, MiscService $miscService) {
$this->configService = $configService;
$this->miscService = $miscService;
}
/**
* {@inheritdoc}
*/
public function search(string $needle): array {
/** @var string $lookup */
try {
$lookup = $this->configService->getGSLookup();
} catch (GSStatusException $e) {
return [];
}
$request = new NCRequest(ConfigService::GS_LOOKUP_USERS, Request::TYPE_GET);
$this->configService->configureRequest($request);
$request->basedOnUrl($lookup);
$request->addParam('search', $needle);
try {
$users = $this->retrieveJson($request);
} catch (
RequestNetworkException |
RequestResultNotJsonException $e
) {
$this->miscService->log(
'Issue while search users from lookup: ' . get_class($e) . ' ' . $e->getMessage()
);
return [];
}
$result = [];
foreach ($users as $user) {
[, $instance] = explode('@', $this->get('federationId', $user), 2);
if ($this->configService->isLocalInstance($instance)) {
continue;
}
$result[] =
new SearchResult(
$this->get('userid.value', $user), DeprecatedMember::TYPE_USER, $instance,
['display' => $this->get('name.value', $user)]
);
}
return $result;
}
}
@@ -0,0 +1,48 @@
<?php
/**
* 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\Search;
use OCA\Circles\ISearch;
use OCA\Circles\Model\DeprecatedMember;
use OCA\Circles\Model\SearchResult;
class LocalGroups implements ISearch {
/**
* {@inheritdoc}
*/
public function search($needle): array {
$result = [];
$groupManager = \OC::$server->getGroupManager();
$groups = $groupManager->search($needle);
foreach ($groups as $group) {
$result[] = new SearchResult($group->getGID(), DeprecatedMember::TYPE_GROUP);
}
return $result;
}
}
@@ -0,0 +1,110 @@
<?php
/**
* 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\Search;
use OCA\Circles\ISearch;
use OCA\Circles\Model\Member;
use OCA\Circles\Model\SearchResult;
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Tools\Traits\TArrayTools;
use OCP\Collaboration\Collaborators\ISearch as ICollaboratorSearch;
use OCP\Share\IShare;
class LocalUsers implements ISearch {
use TArrayTools;
/** @var ICollaboratorSearch */
private $search;
/** @var ConfigService */
private $configService;
/**
* LocalUsers constructor.
*
* @param ICollaboratorSearch $search
* @param ConfigService $configService
*/
public function __construct(
ICollaboratorSearch $search,
ConfigService $configService
) {
$this->search = $search;
$this->configService = $configService;
}
/**
* {@inheritdoc}
*/
public function search($needle): array {
$result = [];
$userManager = \OC::$server->getUserManager();
if ($this->configService->getAppValue(ConfigService::CIRCLES_SEARCH_FROM_COLLABORATOR) === '1') {
return $this->searchFromCollaborator($needle);
}
$users = $userManager->search($needle);
foreach ($users as $user) {
$result[] = new SearchResult(
$user->getUID(),
Member::TYPE_USER,
'',
['display' => $userManager->getDisplayName($user->getUID())]
);
}
return $result;
}
/**
* @param $search
*
* @return array
*/
private function searchFromCollaborator($search): array {
[$temp, $hasMore] = $this->search->search($search, [IShare::TYPE_USER, IShare::TYPE_EMAIL], false, 50, 0);
$result = array_merge($temp['exact']['users'], $temp['users']);
$parsed = [];
foreach ($result as $entry) {
$parsed[] =
new SearchResult(
$this->get('value.shareWith', $entry),
Member::TYPE_USER,
'',
['display' => $this->get('label', $entry)]
);
}
return $parsed;
}
}
@@ -0,0 +1,153 @@
<?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\Search;
use Exception;
use OCA\Circles\Exceptions\ParseMemberLevelException;
use OCA\Circles\Model\Member;
use OCA\Circles\Service\FederatedUserService;
use OCA\Circles\Service\SearchService;
use OCP\IL10N;
use OCP\IUser;
use OCP\Search\IProvider;
use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult;
class UnifiedSearchProvider implements IProvider {
public const PROVIDER_ID = 'circles';
public const ORDER = 9;
/** @var IL10N */
private $l10n;
/** @var FederatedUserService */
private $federatedUserService;
/** @var SearchService */
private $searchService;
/**
* @param IL10N $l10n
* @param FederatedUserService $federatedUserService
* @param SearchService $searchService
*/
public function __construct(
IL10N $l10n,
FederatedUserService $federatedUserService,
SearchService $searchService
) {
$this->l10n = $l10n;
$this->federatedUserService = $federatedUserService;
$this->searchService = $searchService;
}
/**
* return unique id of the provider
*/
public function getId(): string {
return self::PROVIDER_ID;
}
/**
* @return string
*/
public function getName(): string {
return $this->l10n->t('Circles');
}
/**
* @param string $route
* @param array $routeParameters
*
* @return int
*/
public function getOrder(string $route, array $routeParameters): int {
return self::ORDER;
}
/**
* @param IUser $user
* @param ISearchQuery $query
*
* @return SearchResult
*/
public function search(IUser $user, ISearchQuery $query): SearchResult {
$term = $query->getTerm();
$options = $this->extractOptions($term);
$result = [];
try {
$this->federatedUserService->setLocalCurrentUser($user);
$result = $this->searchService->unifiedSearch($term, $options);
} catch (Exception $e) {
}
return SearchResult::paginated(
$this->l10n->t('Circles'),
$result,
($query->getCursor() ?? 0) + $query->getLimit()
);
}
/**
* This is temporary, should be handled by core to extract Options from Term
*
* @param string $term
*
* @return array
*/
private function extractOptions(string &$term): array {
$new = $options = [];
foreach (explode(' ', $term) as $word) {
$word = trim($word);
if (strtolower(substr($word, 0, 3)) === 'is:') {
try {
$options['level'] = Member::parseLevelString(substr($word, 3));
} catch (ParseMemberLevelException $e) {
}
} else {
$new[] = $word;
}
}
$term = trim(implode(' ', $new));
return $options;
}
}
@@ -0,0 +1,171 @@
<?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\Search;
use OCP\Search\SearchResultEntry;
class UnifiedSearchResult extends SearchResultEntry {
/**
* UnifiedSearchResult constructor.
*
* @param string $thumbnailUrl
* @param string $title
* @param string $subline
* @param string $resourceUrl
* @param string $icon
* @param bool $rounded
*/
public function __construct(
string $thumbnailUrl = '',
string $title = '',
string $subline = '',
string $resourceUrl = '',
string $icon = '',
bool $rounded = false
) {
parent::__construct($thumbnailUrl, $title, $subline, $resourceUrl, $icon, $rounded);
}
/**
* @return string
*/
public function getThumbnailUrl(): string {
return $this->thumbnailUrl;
}
/**
* @param string $thumbnailUrl
*
* @return UnifiedSearchResult
*/
public function setThumbnailUrl(string $thumbnailUrl): self {
$this->thumbnailUrl = $thumbnailUrl;
return $this;
}
/**
* @return string
*/
public function getTitle(): string {
return $this->title;
}
/**
* @param string $title
*
* @return UnifiedSearchResult
*/
public function setTitle(string $title): self {
$this->title = $title;
return $this;
}
/**
* @return string
*/
public function getSubline(): string {
return $this->subline;
}
/**
* @param string $subline
*
* @return UnifiedSearchResult
*/
public function setSubline(string $subline): self {
$this->subline = $subline;
return $this;
}
/**
* @return string
*/
public function getResourceUrl(): string {
return $this->resourceUrl;
}
/**
* @param string $resourceUrl
*
* @return UnifiedSearchResult
*/
public function setResourceUrl(string $resourceUrl): self {
$this->resourceUrl = $resourceUrl;
return $this;
}
/**
* @return string
*/
public function getIcon(): string {
return $this->icon;
}
/**
* @param string $icon
*
* @return UnifiedSearchResult
*/
public function setIcon(string $icon): self {
$this->icon = $icon;
return $this;
}
/**
* @return bool
*/
public function isRounded(): bool {
return $this->rounded;
}
/**
* @param bool $rounded
*
* @return UnifiedSearchResult
*/
public function setRounded(bool $rounded): self {
$this->rounded = $rounded;
return $this;
}
}