kopia lustrzana https://github.com/nextcloud/social
compat nc20
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/954/head
rodzic
888d993141
commit
6d9afed842
|
@ -3,3 +3,6 @@ js/
|
|||
node_modules/
|
||||
vendor/
|
||||
img/twemoji/
|
||||
composer/*
|
||||
!composer/composer.json
|
||||
!composer/composer.lock
|
||||
|
|
12
Makefile
12
Makefile
|
@ -64,9 +64,9 @@ clean:
|
|||
clean-dev:
|
||||
rm -rf node_modules
|
||||
|
||||
# composer packages
|
||||
composer:
|
||||
composer install --prefer-dist
|
||||
build-composer:
|
||||
composer install --prefer-dist --working-dir composer
|
||||
composer update --prefer-dist --working-dir composer
|
||||
|
||||
# releasing to github
|
||||
release: appstore github-release github-upload
|
||||
|
@ -88,7 +88,7 @@ github-upload:
|
|||
--file $(build_dir)/$(app_name)-$(version).tar.gz
|
||||
|
||||
# creating .tar.gz + signature
|
||||
appstore: dev-setup lint build-js-production composer
|
||||
appstore: dev-setup lint build-js-production build-composer
|
||||
mkdir -p $(sign_dir)
|
||||
rsync -a \
|
||||
--exclude=/build \
|
||||
|
@ -101,8 +101,8 @@ appstore: dev-setup lint build-js-production composer
|
|||
--exclude=/.babelrc.js \
|
||||
--exclude=/.drone.yml \
|
||||
--exclude=/.eslintrc.js \
|
||||
--exclude=/composer.json \
|
||||
--exclude=/composer.lock \
|
||||
--exclude=/composer/composer.json \
|
||||
--exclude=/composer/composer.lock \
|
||||
--exclude=/src \
|
||||
--exclude=/node_modules \
|
||||
--exclude=/webpack.*.js \
|
||||
|
|
|
@ -1,42 +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\AppInfo;
|
||||
|
||||
|
||||
require_once __DIR__ . '/autoload.php';
|
||||
|
||||
|
||||
/** @var Application $app */
|
||||
$app = \OC::$server->query(Application::class);
|
||||
|
||||
$app->checkUpgradeStatus();
|
||||
$app->registerWebfinger();
|
||||
|
||||
|
|
@ -1,37 +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\AppInfo;
|
||||
|
||||
$composerDir = __DIR__ . '/../vendor/';
|
||||
|
||||
if (is_dir($composerDir) && file_exists($composerDir . 'autoload.php')) {
|
||||
require_once $composerDir . 'autoload.php';
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
<database>pgsql</database>
|
||||
<database>sqlite</database>
|
||||
<database>mysql</database>
|
||||
<nextcloud min-version="17" max-version="19"/>
|
||||
<nextcloud min-version="20" max-version="21"/>
|
||||
</dependencies>
|
||||
|
||||
<background-jobs>
|
||||
|
|
|
@ -12,6 +12,15 @@
|
|||
"config": {
|
||||
"platform": {
|
||||
"php": "7.0.0"
|
||||
},
|
||||
"vendor-dir": ".",
|
||||
"optimize-autoloader": true,
|
||||
"classmap-authoritative": true,
|
||||
"autoloader-suffix": "Social"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"OCA\\Social\\": "../lib/"
|
||||
}
|
||||
},
|
||||
"require": {
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "f93a783c86bad53b0b8486db3fc61380",
|
||||
|
@ -12,12 +12,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/daita/my-small-php-tools.git",
|
||||
"reference": "d8778803612af20699c7efb0637bfe62478e596c"
|
||||
"reference": "4e602526c3afbba7255ae4764037562075ef030f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/d8778803612af20699c7efb0637bfe62478e596c",
|
||||
"reference": "d8778803612af20699c7efb0637bfe62478e596c",
|
||||
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/4e602526c3afbba7255ae4764037562075ef030f",
|
||||
"reference": "4e602526c3afbba7255ae4764037562075ef030f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -40,7 +40,7 @@
|
|||
}
|
||||
],
|
||||
"description": "My small PHP Tools",
|
||||
"time": "2020-03-18T23:09:45+00:00"
|
||||
"time": "2020-08-06T13:26:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "friendica/json-ld",
|
||||
|
@ -243,6 +243,7 @@
|
|||
],
|
||||
"description": "This tool check syntax of PHP files about 20x faster than serial check.",
|
||||
"homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint",
|
||||
"abandoned": "php-parallel-lint/php-parallel-lint",
|
||||
"time": "2018-02-24T15:31:20+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -853,6 +854,7 @@
|
|||
"keywords": [
|
||||
"tokenizer"
|
||||
],
|
||||
"abandoned": true,
|
||||
"time": "2017-11-27T05:48:46+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -1560,16 +1562,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
"version": "v1.17.0",
|
||||
"version": "v1.18.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-ctype.git",
|
||||
"reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9"
|
||||
"reference": "1c302646f6efc070cd46856e600e5e0684d6b454"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e94c8b1bbe2bc77507a1056cdb06451c75b427f9",
|
||||
"reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454",
|
||||
"reference": "1c302646f6efc070cd46856e600e5e0684d6b454",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1581,7 +1583,11 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.17-dev"
|
||||
"dev-master": "1.18-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/polyfill",
|
||||
"url": "https://github.com/symfony/polyfill"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -1614,7 +1620,21 @@
|
|||
"polyfill",
|
||||
"portable"
|
||||
],
|
||||
"time": "2020-05-12T16:14:59+00:00"
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-07-14T12:35:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "theseer/tokenizer",
|
||||
|
@ -1658,23 +1678,24 @@
|
|||
},
|
||||
{
|
||||
"name": "webmozart/assert",
|
||||
"version": "1.8.0",
|
||||
"version": "1.9.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/webmozart/assert.git",
|
||||
"reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6"
|
||||
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6",
|
||||
"reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6",
|
||||
"url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389",
|
||||
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.3.3 || ^7.0",
|
||||
"php": "^5.3.3 || ^7.0 || ^8.0",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
"conflict": {
|
||||
"phpstan/phpstan": "<0.12.20",
|
||||
"vimeo/psalm": "<3.9.1"
|
||||
},
|
||||
"require-dev": {
|
||||
|
@ -1702,7 +1723,7 @@
|
|||
"check",
|
||||
"validate"
|
||||
],
|
||||
"time": "2020-04-18T12:12:48+00:00"
|
||||
"time": "2020-07-08T17:02:28+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
@ -1716,5 +1737,6 @@
|
|||
"platform-dev": [],
|
||||
"platform-overrides": {
|
||||
"php": "7.0.0"
|
||||
}
|
||||
},
|
||||
"plugin-api-version": "1.1.0"
|
||||
}
|
|
@ -31,17 +31,20 @@ declare(strict_types=1);
|
|||
namespace OCA\Social\AppInfo;
|
||||
|
||||
|
||||
use Closure;
|
||||
use OC\DB\SchemaWrapper;
|
||||
use OC\Webfinger\Event\WebfingerEvent;
|
||||
use OC\Webfinger\Model\WebfingerObject;
|
||||
use OC\WellKnown\Event\WellKnownEvent;
|
||||
use OCA\Social\Listeners\WellKnownListener;
|
||||
use OCA\Social\Notification\Notifier;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\UpdateService;
|
||||
use OCA\Social\Service\WebfingerService;
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\IAppContainer;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IServerContainer;
|
||||
use Throwable;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -49,22 +52,12 @@ use OCP\EventDispatcher\IEventDispatcher;
|
|||
*
|
||||
* @package OCA\Social\AppInfo
|
||||
*/
|
||||
class Application extends App {
|
||||
class Application extends App implements IBootstrap {
|
||||
|
||||
|
||||
const APP_NAME = 'social';
|
||||
|
||||
|
||||
/** @var ConfigService */
|
||||
private $configService;
|
||||
|
||||
/** @var UpdateService */
|
||||
private $updateService;
|
||||
|
||||
/** @var IAppContainer */
|
||||
private $container;
|
||||
|
||||
|
||||
/**
|
||||
* Application constructor.
|
||||
*
|
||||
|
@ -72,61 +65,58 @@ class Application extends App {
|
|||
*/
|
||||
public function __construct(array $params = []) {
|
||||
parent::__construct(self::APP_NAME, $params);
|
||||
}
|
||||
|
||||
$this->container = $this->getContainer();
|
||||
|
||||
$manager = $this->container->getServer()
|
||||
->getNotificationManager();
|
||||
/**
|
||||
* @param IRegistrationContext $context
|
||||
*/
|
||||
public function register(IRegistrationContext $context): void {
|
||||
$context->registerEventListener(WellKnownEvent::class, WellKnownListener::class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param IBootContext $context
|
||||
*/
|
||||
public function boot(IBootContext $context): void {
|
||||
$manager = $context->getServerContainer()
|
||||
->getNotificationManager();
|
||||
$manager->registerNotifierService(Notifier::class);
|
||||
|
||||
try {
|
||||
$context->injectFn(Closure::fromCallable([$this, 'checkUpgradeStatus']));
|
||||
} catch (Throwable $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register Navigation Tab
|
||||
*
|
||||
* @param IServerContainer $container
|
||||
*/
|
||||
public function registerWebfinger() {
|
||||
/** @var IEventDispatcher $eventDispatcher */
|
||||
$eventDispatcher = \OC::$server->query(IEventDispatcher::class);
|
||||
$eventDispatcher->addListener(
|
||||
'\OC\Webfinger::onRequest',
|
||||
function(WebfingerEvent $e) {
|
||||
/** @var WebfingerService $webfingerService */
|
||||
$webfingerService = $this->container->query(WebfingerService::class);
|
||||
try {
|
||||
$webfingerService->webfinger($e);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function checkUpgradeStatus() {
|
||||
$upgradeChecked = $this->container->getServer()
|
||||
->getConfig()
|
||||
->getAppValue(Application::APP_NAME, 'update_checked', '');
|
||||
protected function checkUpgradeStatus(IServerContainer $container) {
|
||||
$upgradeChecked = $container->getConfig()
|
||||
->getAppValue(Application::APP_NAME, 'update_checked', '');
|
||||
|
||||
if ($upgradeChecked === '0.3') {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->configService = $this->container->query(ConfigService::class);
|
||||
$this->updateService = $this->container->query(UpdateService::class);
|
||||
$configService = $container->query(ConfigService::class);
|
||||
$updateService = $container->query(UpdateService::class);
|
||||
} catch (QueryException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$server = $this->container->getServer();
|
||||
$schema = new SchemaWrapper($server->getDatabaseConnection());
|
||||
$schema = new SchemaWrapper($container->getDatabaseConnection());
|
||||
if ($schema->hasTable('social_a2_stream')) {
|
||||
$this->updateService->checkUpdateStatus();
|
||||
$updateService->checkUpdateStatus();
|
||||
}
|
||||
|
||||
$this->configService->setAppValue('update_checked', '0.3');
|
||||
$configService->setAppValue('update_checked', '0.3');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
<?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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -37,8 +37,9 @@ use OCA\Social\Exceptions\SocialAppConfigException;
|
|||
use OCA\Social\Exceptions\UnauthorizedFediverseException;
|
||||
use OCA\Social\Model\WebfingerLink;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\WellKnown\Model\IWellKnown;
|
||||
|
||||
class WebfingerService {
|
||||
class WellKnownService {
|
||||
|
||||
|
||||
/** @var IURLGenerator */
|
||||
|
@ -86,17 +87,16 @@ class WebfingerService {
|
|||
|
||||
|
||||
/**
|
||||
* @param WebfingerEvent $event
|
||||
* @param IWellKnown $wellKnown
|
||||
*
|
||||
* @throws CacheActorDoesNotExistException
|
||||
* @throws UnauthorizedFediverseException
|
||||
* @throws SocialAppConfigException
|
||||
* @throws UnauthorizedFediverseException
|
||||
*/
|
||||
public function webfinger(WebfingerEvent $event) {
|
||||
public function webfinger(IWellKnown $wellKnown) {
|
||||
$this->fediverseService->jailed();
|
||||
|
||||
$subject = $event->getWebfinger()
|
||||
->getSubject();
|
||||
$subject = $wellKnown->getSubject();
|
||||
|
||||
if (strpos($subject, 'acct:') === 0) {
|
||||
$subject = substr($subject, 5);
|
||||
|
@ -124,9 +124,8 @@ class WebfingerService {
|
|||
$subscribe = $this->urlGenerator->linkToRouteAbsolute('social.OStatus.subscribe') . '?uri={uri}';
|
||||
$linkOstatus->setTemplate($subscribe);
|
||||
|
||||
$event->getWebfinger()
|
||||
->addLinkSerialized($linkPerson)
|
||||
->addLinkSerialized($linkOstatus);
|
||||
$wellKnown->addLinkSerialized($linkPerson)
|
||||
->addLinkSerialized($linkOstatus);
|
||||
}
|
||||
|
||||
}
|
Ładowanie…
Reference in New Issue