migration to nc21

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/1226/head
Maxence Lange 2021-03-18 11:45:39 -01:00
rodzic b2b285168b
commit 9773264678
13 zmienionych plików z 258 dodań i 342 usunięć

Wyświetl plik

@ -18,7 +18,7 @@
**🕸 Open standards:** We use the established ActivityPub standard!
]]></description>
<version>0.4.2</version>
<version>0.5.0</version>
<licence>agpl</licence>
<author mail="maxence@artificial-owl.com" homepage="https://artificial-owl.com/">Maxence Lange</author>
<author mail="jus@bitgrid.net">Julius Härtl</author>
@ -35,7 +35,7 @@
<database>pgsql</database>
<database>sqlite</database>
<database>mysql</database>
<nextcloud min-version="20" max-version="21"/>
<nextcloud min-version="21" max-version="21"/>
</dependencies>
<background-jobs>

143
composer.lock wygenerowano
Wyświetl plik

@ -12,17 +12,18 @@
"source": {
"type": "git",
"url": "https://github.com/daita/my-small-php-tools.git",
"reference": "aeed155a9c0cf79153bc9703d1792b0361162dd3"
"reference": "fe188b6459806eb4577b2c5ea8e0f46cb9873281"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/aeed155a9c0cf79153bc9703d1792b0361162dd3",
"reference": "aeed155a9c0cf79153bc9703d1792b0361162dd3",
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/fe188b6459806eb4577b2c5ea8e0f46cb9873281",
"reference": "fe188b6459806eb4577b2c5ea8e0f46cb9873281",
"shasum": ""
},
"require": {
"php": "^7.0"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
@ -40,7 +41,11 @@
}
],
"description": "My small PHP Tools",
"time": "2020-12-01T00:47:38+00:00"
"support": {
"issues": "https://github.com/daita/my-small-php-tools/issues",
"source": "https://github.com/daita/my-small-php-tools/tree/master"
},
"time": "2021-03-17T16:33:37+00:00"
},
{
"name": "friendica/json-ld",
@ -139,6 +144,10 @@
"resize",
"scale"
],
"support": {
"issues": "https://github.com/gumlet/php-image-resize/issues",
"source": "https://github.com/gumlet/php-image-resize/tree/2.0.0"
},
"time": "2020-07-04T21:04:16+00:00"
}
],
@ -195,6 +204,10 @@
"constructor",
"instantiate"
],
"support": {
"issues": "https://github.com/doctrine/instantiator/issues",
"source": "https://github.com/doctrine/instantiator/tree/master"
},
"time": "2015-06-14T21:17:01+00:00"
},
{
@ -243,6 +256,10 @@
],
"description": "This tool check syntax of PHP files about 20x faster than serial check.",
"homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint",
"support": {
"issues": "https://github.com/JakubOnderka/PHP-Parallel-Lint/issues",
"source": "https://github.com/JakubOnderka/PHP-Parallel-Lint/tree/master"
},
"abandoned": "php-parallel-lint/php-parallel-lint",
"time": "2018-02-24T15:31:20+00:00"
},
@ -289,6 +306,10 @@
"object",
"object graph"
],
"support": {
"issues": "https://github.com/myclabs/DeepCopy/issues",
"source": "https://github.com/myclabs/DeepCopy/tree/1.x"
},
"time": "2017-10-19T19:58:43+00:00"
},
{
@ -344,6 +365,10 @@
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"support": {
"issues": "https://github.com/phar-io/manifest/issues",
"source": "https://github.com/phar-io/manifest/tree/master"
},
"time": "2017-03-05T18:14:27+00:00"
},
{
@ -391,6 +416,10 @@
}
],
"description": "Library for handling version information and constraints",
"support": {
"issues": "https://github.com/phar-io/version/issues",
"source": "https://github.com/phar-io/version/tree/master"
},
"time": "2017-03-05T17:38:23+00:00"
},
{
@ -445,6 +474,10 @@
"reflection",
"static analysis"
],
"support": {
"issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
"source": "https://github.com/phpDocumentor/ReflectionCommon/tree/master"
},
"time": "2017-09-11T18:02:19+00:00"
},
{
@ -497,6 +530,10 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"support": {
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/release/4.x"
},
"time": "2019-12-28T18:55:12+00:00"
},
{
@ -542,6 +579,10 @@
"email": "me@mikevanriel.com"
}
],
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
"source": "https://github.com/phpDocumentor/TypeResolver/tree/master"
},
"time": "2017-12-30T13:23:38+00:00"
},
{
@ -605,6 +646,10 @@
"spy",
"stub"
],
"support": {
"issues": "https://github.com/phpspec/prophecy/issues",
"source": "https://github.com/phpspec/prophecy/tree/v1.10.3"
},
"time": "2020-03-05T15:02:03+00:00"
},
{
@ -668,6 +713,10 @@
"testing",
"xunit"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/5.3"
},
"time": "2018-04-06T15:36:58+00:00"
},
{
@ -715,6 +764,11 @@
"filesystem",
"iterator"
],
"support": {
"irc": "irc://irc.freenode.net/phpunit",
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/1.4.5"
},
"time": "2017-11-27T13:52:08+00:00"
},
{
@ -756,6 +810,10 @@
"keywords": [
"template"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-text-template/issues",
"source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1"
},
"time": "2015-06-21T13:50:34+00:00"
},
{
@ -805,6 +863,10 @@
"keywords": [
"timer"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-timer/issues",
"source": "https://github.com/sebastianbergmann/php-timer/tree/master"
},
"time": "2017-02-26T11:10:40+00:00"
},
{
@ -854,6 +916,10 @@
"keywords": [
"tokenizer"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-token-stream/issues",
"source": "https://github.com/sebastianbergmann/php-token-stream/tree/master"
},
"abandoned": true,
"time": "2017-11-27T05:48:46+00:00"
},
@ -939,6 +1005,10 @@
"testing",
"xunit"
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/6.5.14"
},
"time": "2019-02-01T05:22:47+00:00"
},
{
@ -998,6 +1068,10 @@
"mock",
"xunit"
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues",
"source": "https://github.com/sebastianbergmann/phpunit-mock-objects/tree/5.0.10"
},
"abandoned": true,
"time": "2018-08-09T05:50:03+00:00"
},
@ -1044,6 +1118,10 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"support": {
"issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
"source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -1114,6 +1192,10 @@
"compare",
"equality"
],
"support": {
"issues": "https://github.com/sebastianbergmann/comparator/issues",
"source": "https://github.com/sebastianbergmann/comparator/tree/master"
},
"time": "2018-02-01T13:46:46+00:00"
},
{
@ -1166,6 +1248,10 @@
"keywords": [
"diff"
],
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
"source": "https://github.com/sebastianbergmann/diff/tree/master"
},
"time": "2017-08-03T08:09:46+00:00"
},
{
@ -1216,6 +1302,10 @@
"environment",
"hhvm"
],
"support": {
"issues": "https://github.com/sebastianbergmann/environment/issues",
"source": "https://github.com/sebastianbergmann/environment/tree/master"
},
"time": "2017-07-01T08:51:00+00:00"
},
{
@ -1283,6 +1373,10 @@
"export",
"exporter"
],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
"source": "https://github.com/sebastianbergmann/exporter/tree/3.1.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -1340,6 +1434,10 @@
"keywords": [
"global state"
],
"support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/2.0.0"
},
"time": "2017-04-27T15:39:26+00:00"
},
{
@ -1387,6 +1485,10 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-enumerator/issues",
"source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -1438,6 +1540,10 @@
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-reflector/issues",
"source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.2"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -1497,6 +1603,10 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"support": {
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
"source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -1545,6 +1655,10 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"support": {
"issues": "https://github.com/sebastianbergmann/resource-operations/issues",
"source": "https://github.com/sebastianbergmann/resource-operations/tree/master"
},
"time": "2015-07-28T20:34:47+00:00"
},
{
@ -1588,6 +1702,10 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"support": {
"issues": "https://github.com/sebastianbergmann/version/issues",
"source": "https://github.com/sebastianbergmann/version/tree/master"
},
"time": "2016-10-03T07:35:21+00:00"
},
{
@ -1650,6 +1768,9 @@
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.19.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -1704,6 +1825,10 @@
}
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"support": {
"issues": "https://github.com/theseer/tokenizer/issues",
"source": "https://github.com/theseer/tokenizer/tree/master"
},
"time": "2019-06-13T22:48:21+00:00"
},
{
@ -1711,12 +1836,12 @@
"version": "1.9.1",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
"url": "https://github.com/webmozarts/assert.git",
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389",
"url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389",
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389",
"shasum": ""
},
@ -1753,6 +1878,10 @@
"check",
"validate"
],
"support": {
"issues": "https://github.com/webmozarts/assert/issues",
"source": "https://github.com/webmozarts/assert/tree/1.9.1"
},
"time": "2020-07-08T17:02:28+00:00"
}
],
@ -1768,5 +1897,5 @@
"platform-overrides": {
"php": "7.0.0"
},
"plugin-api-version": "1.1.0"
"plugin-api-version": "2.0.0"
}

Wyświetl plik

@ -33,6 +33,7 @@ namespace OCA\Social\AppInfo;
use Closure;
use OC\DB\SchemaWrapper;
use OCA\Social\Handlers\WebfingerHandler;
use OCA\Social\Notification\Notifier;
use OCA\Social\Search\UnifiedSearchProvider;
use OCA\Social\Service\ConfigService;
@ -73,9 +74,7 @@ class Application extends App implements IBootstrap {
*/
public function register(IRegistrationContext $context): void {
$context->registerSearchProvider(UnifiedSearchProvider::class);
// TODO: nc21, uncomment
// $context->registerEventListener(WellKnownEvent::class, WellKnownListener::class);
$context->registerWellKnownHandler(WebfingerHandler::class);
}
@ -86,40 +85,6 @@ class Application extends App implements IBootstrap {
$manager = $context->getServerContainer()
->getNotificationManager();
$manager->registerNotifierService(Notifier::class);
try {
$context->injectFn(Closure::fromCallable([$this, 'checkUpgradeStatus']));
} catch (Throwable $e) {
}
}
/**
* Register Navigation Tab
*
* @param IServerContainer $container
*/
protected function checkUpgradeStatus(IServerContainer $container) {
$upgradeChecked = $container->getConfig()
->getAppValue(Application::APP_NAME, 'update_checked', '');
if ($upgradeChecked === '0.3') {
return;
}
try {
$configService = $container->query(ConfigService::class);
$updateService = $container->query(UpdateService::class);
} catch (QueryException $e) {
return;
}
$schema = new SchemaWrapper($container->getDatabaseConnection());
if ($schema->hasTable('social_a2_stream')) {
$updateService->checkUpdateStatus();
}
$configService->setAppValue('update_checked', '0.3');
}
}

Wyświetl plik

@ -186,9 +186,6 @@ class Reset extends Base {
*
*/
private function uninstallWellKnown() {
if ($this->configService->getCoreValue('public_webfinger') === 'social/lib/webfinger.php') {
$this->configService->unsetCoreValue('public_webfinger');
}
if ($this->configService->getCoreValue('public_host-meta') === 'social/lib/hostmeta.php') {
$this->configService->unsetCoreValue('public_host-meta');
}

Wyświetl plik

@ -39,7 +39,6 @@ use OCA\Social\Exceptions\CacheActorDoesNotExistException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Exceptions\StreamNotFoundException;
use OCA\Social\Exceptions\UrlCloudException;
use OCA\Social\Model\ActivityPub\Actor\Person;
use OCA\Social\Service\AccountService;
use OCA\Social\Service\CacheActorService;
use OCA\Social\Service\ConfigService;
@ -71,6 +70,9 @@ class SocialPubController extends Controller {
/** @var IL10N */
private $l10n;
/** @var IInitialStateService */
private $initialStateService;
/** @var NavigationController */
private $navigationController;
@ -91,6 +93,7 @@ class SocialPubController extends Controller {
* SocialPubController constructor.
*
* @param $userId
* @param IInitialStateService $initialStateService
* @param IRequest $request
* @param IL10N $l10n
* @param NavigationController $navigationController
@ -100,9 +103,9 @@ class SocialPubController extends Controller {
* @param ConfigService $configService
*/
public function __construct(
$userId, IInitialStateService $initialStateService, IRequest $request, IL10N $l10n, NavigationController $navigationController,
CacheActorService $cacheActorService, AccountService $accountService, StreamService $streamService,
ConfigService $configService
$userId, IInitialStateService $initialStateService, IRequest $request, IL10N $l10n,
NavigationController $navigationController, CacheActorService $cacheActorService,
AccountService $accountService, StreamService $streamService, ConfigService $configService
) {
parent::__construct(Application::APP_NAME, $request);
@ -143,9 +146,11 @@ class SocialPubController extends Controller {
return $this->fail($e);
}
$this->initialStateService->provideInitialState('social', 'serverData', [
'public' => true,
]);
$this->initialStateService->provideInitialState(
'social', 'serverData', [
'public' => true,
]
);
$page = new PublicTemplateResponse(Application::APP_NAME, 'main', $data);
$page->setStatus($status);
$page->setHeaderTitle($this->l10n->t('Social'));
@ -236,10 +241,13 @@ class SocialPubController extends Controller {
'application' => 'Social'
];
$this->initialStateService->provideInitialState(Application::APP_NAME, 'item', $stream );
$this->initialStateService->provideInitialState(Application::APP_NAME, 'serverData', [
'public' => ($this->userId === null),
]);
$this->initialStateService->provideInitialState(Application::APP_NAME, 'item', $stream);
$this->initialStateService->provideInitialState(
Application::APP_NAME, 'serverData', [
'public' => ($this->userId === null),
]
);
return new TemplateResponse(Application::APP_NAME, 'main', $data);
}

Wyświetl plik

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
@ -9,7 +11,7 @@ declare(strict_types=1);
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @copyright 2021, Maxence Lange <maxence@artificial-owl.com>
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@ -27,19 +29,34 @@ declare(strict_types=1);
*
*/
namespace OCA\Social\Service;
namespace OCA\Social\Handlers;
use OC\Webfinger\Event\WebfingerEvent;
use daita\MySmallPhpTools\Traits\TArrayTools;
use OCA\Social\Db\CacheActorsRequest;
use OCA\Social\Exceptions\CacheActorDoesNotExistException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Exceptions\UnauthorizedFediverseException;
use OCA\Social\Model\WebfingerLink;
use OCA\Social\Service\CacheActorService;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\FediverseService;
use OCP\Http\WellKnown\IHandler;
use OCP\Http\WellKnown\IRequestContext;
use OCP\Http\WellKnown\IResponse;
use OCP\Http\WellKnown\JrdResponse;
use OCP\IURLGenerator;
use OCP\WellKnown\Model\IWellKnown;
class WellKnownService {
/**
* Class WebfingerHandler
*
* @package OCA\Social\Handlers
*/
class WebfingerHandler implements IHandler {
use TArrayTools;
/** @var IURLGenerator */
@ -48,55 +65,57 @@ class WellKnownService {
/** @var CacheActorsRequest */
private $cacheActorsRequest;
/** @var CacheActorService */
private $cacheActorService;
/** @var FediverseService */
private $fediverseService;
/** @var CacheActorService */
private $cacheActorService;
/** @var ConfigService */
private $configService;
/** @var MiscService */
private $miscService;
/**
* WebfingerService constructor.
* WebfingerHandler constructor.
*
* @param IURLGenerator $urlGenerator
* @param CacheActorsRequest $cacheActorsRequest
* @param CacheActorService $cacheActorService
* @param FediverseService $fediverseService
* @param CacheActorService $cacheActorService
* @param ConfigService $configService
* @param MiscService $miscService
*/
public function __construct(
IURLGenerator $urlGenerator, CacheActorsRequest $cacheActorsRequest,
CacheActorService $cacheActorService, FediverseService $fediverseService,
ConfigService $configService, MiscService $miscService
FediverseService $fediverseService, CacheActorService $cacheActorService, ConfigService $configService
) {
$this->urlGenerator = $urlGenerator;
$this->cacheActorsRequest = $cacheActorsRequest;
$this->cacheActorService = $cacheActorService;
$this->fediverseService = $fediverseService;
$this->cacheActorService = $cacheActorService;
$this->configService = $configService;
$this->miscService = $miscService;
}
/**
* @param IWellKnown $wellKnown
* @param string $service
* @param IRequestContext $context
* @param IResponse|null $response
*
* @return IResponse|null
* @throws CacheActorDoesNotExistException
* @throws SocialAppConfigException
* @throws UnauthorizedFediverseException
* @throws SocialAppConfigException
*/
public function webfinger(IWellKnown $wellKnown) {
public function handle(string $service, IRequestContext $context, ?IResponse $response): ?IResponse {
$this->fediverseService->jailed();
if ($service !== 'webfinger') {
return $response;
}
$subject = $wellKnown->getSubject();
$subject = $this->get('resource', $context->getHttpRequest()->getParams());
if (!($response instanceof JrdResponse)) {
$response = new JrdResponse($subject);
}
if (strpos($subject, 'acct:') === 0) {
$subject = substr($subject, 5);
@ -114,18 +133,20 @@ class WellKnownService {
$href = $this->configService->getSocialUrl() . '@' . $actor->getPreferredUsername();
$href = rtrim($href, '/');
$linkPerson = new WebfingerLink();
$linkPerson->setRel('self');
$linkPerson->setType('application/activity+json');
$linkPerson->setHref($href);
$response->addLink('self', 'application/activity+json', $href, []);
$linkOstatus = new WebfingerLink();
$linkOstatus->setRel('http://ostatus.org/schema/1.0/subscribe');
$subscribe = $this->urlGenerator->linkToRouteAbsolute('social.OStatus.subscribe') . '?uri={uri}';
$linkOstatus->setTemplate($subscribe);
// not supported ?
// $subscribe = $this->urlGenerator->linkToRouteAbsolute('social.OStatus.subscribe') . '?uri={uri}';
// $response->addLink(
// 'http://ostatus.org/schema/1.0/subscribe',
// '',
// '',
// null,
// null,
// ['template' => $subscribe]
// );
$wellKnown->addLinkSerialized($linkPerson)
->addLinkSerialized($linkOstatus);
return $response;
}
}

Wyświetl plik

@ -1,83 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* 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 2020, Maxence Lange <maxence@artificial-owl.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 OCA\Social\Listeners;
use OC\WellKnown\Event\WellKnownEvent;
use OCA\Social\Exceptions\CacheActorDoesNotExistException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Exceptions\UnauthorizedFediverseException;
use OCA\Social\Service\WellKnownService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\WellKnown\IWellKnownManager;
/**
* Class WellKnownListener
*
* @package OCA\Social\Listeners
*/
class WellKnownListener implements IEventListener {
private $wellKnownService;
/**
* WellKnownListener constructor.
*
* @param WellKnownService $wellKnownService
*/
public function __construct(WellKnownService $wellKnownService) {
$this->wellKnownService = $wellKnownService;
}
/**
* @param Event $event
*/
public function handle(Event $event): void {
if (!$event instanceof WellKnownEvent) {
return;
}
$wellKnown = $event->getWellKnown();
if ($wellKnown->getService() === IWellKnownManager::WEBFINGER) {
try {
$this->wellKnownService->webfinger($wellKnown);
} catch (CacheActorDoesNotExistException | SocialAppConfigException | UnauthorizedFediverseException $e) {
}
}
}
}

Wyświetl plik

@ -32,7 +32,7 @@ namespace OCA\Social\Migration;
use Closure;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Exception;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
@ -225,20 +225,20 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
]
);
$table->addColumn(
'summary', Type::TEXT,
'summary', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'public_key', Type::TEXT,
'public_key', Types::TEXT,
[
'notnull' => false
]
);
$table->addColumn(
'private_key', Type::TEXT,
'private_key', Types::TEXT,
[
'notnull' => false
]
@ -542,7 +542,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
]
);
$table->addColumn(
'chunk', Type::SMALLINT,
'chunk', Types::SMALLINT,
[
'default' => 1,
'length' => 1,
@ -565,7 +565,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
]
);
$table->addColumn(
'subtype', Type::STRING,
'subtype', Types::STRING,
[
'notnull' => false,
'length' => 31,
@ -581,35 +581,35 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
]
);
$table->addColumn(
'to_array', Type::TEXT,
'to_array', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'cc', Type::TEXT,
'cc', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'bcc', Type::TEXT,
'bcc', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'content', Type::TEXT,
'content', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'summary', Type::TEXT,
'summary', Types::TEXT,
[
'notnull' => false,
'default' => ''
@ -686,42 +686,42 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
]
);
$table->addColumn(
'hashtags', Type::TEXT,
'hashtags', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'details', Type::TEXT,
'details', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'source', Type::TEXT,
'source', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'instances', Type::TEXT,
'instances', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'attachments', Type::TEXT,
'attachments', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'cache', Type::TEXT,
'cache', Types::TEXT,
[
'notnull' => false,
'default' => ''
@ -902,28 +902,28 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
]
);
$table->addColumn(
'summary', Type::TEXT,
'summary', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'public_key', Type::TEXT,
'public_key', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'source', Type::TEXT,
'source', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'details', Type::TEXT,
'details', Types::TEXT,
[
'notnull' => false
]
@ -1012,7 +1012,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
]
);
$table->addColumn(
'resized_copy', Type::TEXT,
'resized_copy', Types::TEXT,
[
'notnull' => false,
'default' => ''
@ -1203,14 +1203,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
]
);
$table->addColumn(
'activity', Type::TEXT,
'activity', Types::TEXT,
[
'notnull' => false,
'default' => ''
]
);
$table->addColumn(
'instance', Type::TEXT,
'instance', Types::TEXT,
[
'notnull' => false,
'length' => 500,
@ -1263,7 +1263,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
$table = $schema->createTable('social_3_stream_act');
$table->addColumn(
'id', Type::INTEGER,
'id', Types::INTEGER,
[
'autoincrement' => true,
'notnull' => true,
@ -1272,7 +1272,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
]
);
$table->addColumn(
'chunk', Type::SMALLINT,
'chunk', Types::SMALLINT,
[
'default' => 1,
'length' => 1,
@ -1315,7 +1315,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
$table->addColumn('boosted', 'boolean', ['default' => false]);
$table->addColumn('replied', 'boolean', ['default' => false]);
$table->addColumn(
'values', Type::TEXT,
'values', Types::TEXT,
[
'notnull' => false,
'default' => ''
@ -1338,7 +1338,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
$table = $schema->createTable('social_3_stream_dest');
$table->addColumn(
'chunk', Type::SMALLINT,
'chunk', Types::SMALLINT,
[
'default' => 1,
'length' => 1,

Wyświetl plik

@ -33,7 +33,7 @@ namespace OCA\Social\Migration;
use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Exception;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
@ -139,7 +139,7 @@ class Version0003Date20200823023911 extends SimpleMigrationStep {
[
'length' => 11,
'unsigned' => true,
'notnull' => false,
'notnull' => false,
]
);
}
@ -440,7 +440,7 @@ class Version0003Date20200823023911 extends SimpleMigrationStep {
}
$table->addColumn(
'chunk', Type::SMALLINT,
'chunk', Types::SMALLINT,
[
'default' => 1,
'length' => 1,

Wyświetl plik

@ -245,7 +245,7 @@ class AccountService {
/* we do nohtin */
}
$this->configService->setCoreValue('public_webfinger', 'social/lib/webfinger.php');
// $this->configService->setCoreValue('public_webfinger', 'social/lib/webfinger.php');
$this->configService->setCoreValue('public_host-meta', 'social/lib/hostmeta.php');
$actor = new Person();

Wyświetl plik

@ -200,7 +200,7 @@ class CheckService {
* @return array
*/
public function checkInstallationStatus(bool $light = false): array {
$this->configService->setCoreValue('public_webfinger', 'social/lib/webfinger.php');
// $this->configService->setCoreValue('public_webfinger', 'social/lib/webfinger.php');
$this->configService->setCoreValue('public_host-meta', 'social/lib/hostmeta.php');
$result = [];

Wyświetl plik

@ -1,129 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* 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 2018, Maxence Lange <maxence@artificial-owl.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 OCA\Social;
use Exception;
use OC;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Service\CacheActorService;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\FediverseService;
use OCP\AppFramework\QueryException;
require_once(__DIR__ . '/../vendor/autoload.php');
if (!array_key_exists('resource', $_GET)) {
echo 'missing resource';
exit();
}
$subject = $_GET['resource'];
$urlGenerator = OC::$server->getURLGenerator();
$type = '';
if (strpos($subject, 'acct:') === 0) {
list($type, $account) = explode(':', $subject, 2);
$type .= ':';
} else {
$account = $subject;
}
list($username, $instance) = explode('@', $account);
try {
/** @var CacheActorService $cacheActorService */
$cacheActorService = OC::$server->query(CacheActorService::class);
/** @var FediverseService $fediverseService */
$fediverseService = OC::$server->query(FediverseService::class);
/** @var ConfigService $configService */
$configService = OC::$server->query(ConfigService::class);
} catch (QueryException $e) {
OC::$server->getLogger()
->log(1, 'QueryException - ' . $e->getMessage());
http_response_code(404);
exit;
}
try {
$fediverseService->jailed();
$cacheActorService->getFromLocalAccount($username);
} catch (Exception $e) {
if ($type !== '') {
OC::$server->getLogger()
->log(1, 'Exception on webfinger/fromAccount - ' . $e->getMessage());
http_response_code(404);
exit;
}
try {
$fromId = $cacheActorService->getFromId($subject);
$instance = $configService->getSocialAddress();
$username = $fromId->getPreferredUsername();
} catch (Exception $e) {
OC::$server->getLogger()
->log(1, 'Exception on webfinger/fromId - ' . $e->getMessage());
http_response_code(404);
exit;
}
}
try {
$href = $configService->getSocialUrl() . '@' . $username;
} catch (SocialAppConfigException $e) {
http_response_code(404);
exit;
}
if (substr($href, -1) === '/') {
$href = substr($href, 0, -1);
}
$finger = [
'subject' => $type . $username . '@' . $instance,
'links' => [
[
'rel' => 'self',
'type' => 'application/activity+json',
'href' => $href
],
[
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
'template' => urldecode(
$href = $urlGenerator->linkToRouteAbsolute('social.OStatus.subscribe') . '?uri={uri}'
)
]
]
];
header('Content-type: application/json');
echo json_encode($finger);

14
package-lock.json wygenerowano
Wyświetl plik

@ -10108,7 +10108,8 @@
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
"dev": true
"dev": true,
"optional": true
},
"hammerjs": {
"version": "2.0.8",
@ -10999,6 +11000,7 @@
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
"dev": true,
"optional": true,
"requires": {
"is-docker": "^2.0.0"
}
@ -15421,6 +15423,7 @@
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
"dev": true,
"optional": true,
"requires": {
"growly": "^1.3.0",
"is-wsl": "^2.2.0",
@ -15435,6 +15438,7 @@
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"optional": true,
"requires": {
"yallist": "^4.0.0"
}
@ -15444,6 +15448,7 @@
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
"dev": true,
"optional": true,
"requires": {
"lru-cache": "^6.0.0"
}
@ -15453,6 +15458,7 @@
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"optional": true,
"requires": {
"isexe": "^2.0.0"
}
@ -15461,7 +15467,8 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
"dev": true,
"optional": true
}
}
},
@ -18191,7 +18198,8 @@
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
"dev": true
"dev": true,
"optional": true
},
"sigmund": {
"version": "1.0.1",