diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2020-06-19 00:02:54 -0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-19 00:02:54 -0100 |
commit | 97fb063479d4c0ad6fccdea3774601a619f8a886 (patch) | |
tree | 803b11f682fb22f09c31e3158d1b4ab0576fd842 | |
parent | bcf76667f7243d2c6078a7c9dbb7429f2b201963 (diff) | |
parent | 0888efd78a56432b7ec0bc11d79c4dbc553c2214 (diff) |
Merge pull request #912 from nextcloud/new-database
new db, multiple fixes
55 files changed, 707 insertions, 2712 deletions
diff --git a/appinfo/info.xml b/appinfo/info.xml index 6eeb233f..4bda7b49 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -18,7 +18,7 @@ **🕸 Open standards:** We use the established ActivityPub standard! ]]></description> - <version>0.2.101</version> + <version>0.3</version> <licence>agpl</licence> <author mail="maxence@artificial-owl.com">Maxence Lange</author> <author mail="jus@bitgrid.net">Julius Härtl</author> @@ -32,7 +32,7 @@ <repository type="git">https://github.com/nextcloud/social.git</repository> <screenshot>https://raw.githubusercontent.com/nextcloud/social/master/img/screenshot.png</screenshot> <dependencies> - <nextcloud min-version="15" max-version="17"/> + <nextcloud min-version="15" max-version="19"/> <database>pgsql</database> <database>sqlite</database> <database>mysql</database> diff --git a/appinfo/routes.php b/appinfo/routes.php index b7e5d6e6..e462d5dd 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -52,16 +52,18 @@ return [ ['name' => 'ActivityPub#actorAlias', 'url' => '/@{username}/', 'verb' => 'GET'], ['name' => 'ActivityPub#inbox', 'url' => '/@{username}/inbox', 'verb' => 'POST'], ['name' => 'ActivityPub#sharedInbox', 'url' => '/inbox', 'verb' => 'POST'], - ['name' => 'ActivityPub#outbox', 'url' => '/@{username}/outbox', 'verb' => 'POST'], + + ['name' => 'ActivityPub#outbox', 'url' => '/@{username}/outbox', 'verb' => 'GET'], + ['name' => 'ActivityPub#outbox', 'url' => '/@{username}/outbox', 'verb' => 'POST'], // Check if needed ['name' => 'ActivityPub#followers', 'url' => '/@{username}/followers', 'verb' => 'GET'], ['name' => 'ActivityPub#following', 'url' => '/@{username}/following', 'verb' => 'GET'], - ['name' => 'OStatus#subscribe', 'url' => '/ostatus/follow/{uri}', 'verb' => 'GET'], + ['name' => 'ActivityPub#displayPost', 'url' => '/@{username}/{token}', 'verb' => 'GET'], + + ['name' => 'OStatus#subscribe', 'url' => '/ostatus/follow/', 'verb' => 'GET'], ['name' => 'OStatus#followRemote', 'url' => '/api/v1/ostatus/followRemote/{local}', 'verb' => 'GET'], ['name' => 'OStatus#getLink', 'url' => '/api/v1/ostatus/link/{local}/{account}', 'verb' => 'GET'], - ['name' => 'ActivityPub#displayPost', 'url' => '/@{username}/{token}', 'verb' => 'GET'], - ['name' => 'Local#streamHome', 'url' => '/api/v1/stream/home', 'verb' => 'GET'], ['name' => 'Local#streamNotifications', 'url' => '/api/v1/stream/notifications', 'verb' => 'GET'], ['name' => 'Local#streamTimeline', 'url' => '/api/v1/stream/timeline', 'verb' => 'GET'], diff --git a/composer.lock b/composer.lock index 0836bdf8..758e0955 100644 --- a/composer.lock +++ b/composer.lock @@ -12,12 +12,12 @@ "source": { "type": "git", "url": "https://github.com/daita/my-small-php-tools.git", - "reference": "2252b8e425e68331e70d4cfad412274af12e5c6f" + "reference": "d8778803612af20699c7efb0637bfe62478e596c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/2252b8e425e68331e70d4cfad412274af12e5c6f", - "reference": "2252b8e425e68331e70d4cfad412274af12e5c6f", + "url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/d8778803612af20699c7efb0637bfe62478e596c", + "reference": "d8778803612af20699c7efb0637bfe62478e596c", "shasum": "" }, "require": { @@ -40,7 +40,7 @@ } ], "description": "My small PHP Tools", - "time": "2019-10-03T11:59:56+00:00" + "time": "2020-03-18T23:09:45+00:00" }, { "name": "friendica/json-ld", @@ -448,16 +448,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.2", + "version": "4.3.4", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", "shasum": "" }, "require": { @@ -469,6 +469,7 @@ "require-dev": { "doctrine/instantiator": "^1.0.5", "mockery/mockery": "^1.0", + "phpdocumentor/type-resolver": "0.4.*", "phpunit/phpunit": "^6.4" }, "type": "library", @@ -495,7 +496,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-09-12T14:27:41+00:00" + "time": "2019-12-28T18:55:12+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -544,33 +545,33 @@ }, { "name": "phpspec/prophecy", - "version": "1.9.0", + "version": "v1.10.3", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" + "reference": "451c3cd1418cf640de218914901e51b064abb093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", + "reference": "451c3cd1418cf640de218914901e51b064abb093", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", + "phpspec/phpspec": "^2.5 || ^3.2", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { @@ -603,7 +604,7 @@ "spy", "stub" ], - "time": "2019-10-03T11:07:50+00:00" + "time": "2020-03-05T15:02:03+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1559,16 +1560,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.12.0", + "version": "v1.17.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4" + "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9", "shasum": "" }, "require": { @@ -1580,7 +1581,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.17-dev" } }, "autoload": { @@ -1613,7 +1614,7 @@ "polyfill", "portable" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2020-05-12T16:14:59+00:00" }, { "name": "theseer/tokenizer", @@ -1657,31 +1658,29 @@ }, { "name": "webmozart/assert", - "version": "1.5.0", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4" + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/88e6d84706d09a236046d686bbea96f07b3a34f4", - "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4", + "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6", + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6", "shasum": "" }, "require": { "php": "^5.3.3 || ^7.0", "symfony/polyfill-ctype": "^1.8" }, + "conflict": { + "vimeo/psalm": "<3.9.1" + }, "require-dev": { "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -1703,7 +1702,7 @@ "check", "validate" ], - "time": "2019-08-24T08:43:50+00:00" + "time": "2020-04-18T12:12:48+00:00" } ], "aliases": [], @@ -307,7 +307,7 @@ class AP { case Announce::TYPE: $item = new Announce(); - $item->setHiddenOnTimeline(true); + $item->setFilterDuplicate(true); break; case Block::TYPE: diff --git a/lib/Command/CheckInstall.php b/lib/Command/CheckInstall.php index 4a2cd6a8..c01d85fb 100644 --- a/lib/Command/CheckInstall.php +++ b/lib/Command/CheckInstall.php @@ -177,7 +177,8 @@ class CheckInstall extends Base { throw new Exception('unknown user'); } - $wrapper = $this->pushService->testOnAccount($userId); + // push was not implemented on 18 +// $wrapper = $this->pushService->testOnAccount($userId); $output->writeln(json_encode($wrapper, JSON_PRETTY_PRINT)); diff --git a/lib/Command/StreamDetails.php b/lib/Command/StreamDetails.php index f6e952b5..3d8a5956 100644 --- a/lib/Command/StreamDetails.php +++ b/lib/Command/StreamDetails.php @@ -138,7 +138,7 @@ class StreamDetails extends ExtendedBase { $this->output->writeln('* <info>Direct</info>: ' . json_encode($direct, JSON_PRETTY_PRINT)); $this->output->writeln('* <info>Public</info>: ' . ($details->isPublic() ? 'true' : 'false')); - $this->output->writeln('* <info>Federated</info>: ' . ($details->isFederated() ? 'true' : 'true')); + $this->output->writeln('* <info>Federated</info>: ' . ($details->isFederated() ? 'true' : 'false')); } } diff --git a/lib/Command/Timeline.php b/lib/Command/Timeline.php index 2379cb93..6dc5e1c8 100644 --- a/lib/Command/Timeline.php +++ b/lib/Command/Timeline.php @@ -139,7 +139,6 @@ class Timeline extends ExtendedBase { } - /** * @param Person $actor * @param string $timeline @@ -147,19 +146,25 @@ class Timeline extends ExtendedBase { * @throws Exception */ private function displayStream(Person $actor, string $timeline) { + $this->streamRequest->setViewer($actor); switch ($timeline) { case 'home': - $stream = $this->streamRequest->getTimelineHome($actor, 0, $this->count); + $stream = $this->streamRequest->getTimelineHome(0, $this->count); $this->outputStreams($stream); break; case 'direct': - $stream = $this->streamRequest->getTimelineDirect($actor, 0, $this->count); + $stream = $this->streamRequest->getTimelineDirect(0, $this->count); $this->outputStreams($stream); break; case 'notifications': - $stream = $this->streamRequest->getTimelineNotifications($actor, 0, $this->count); + $stream = $this->streamRequest->getTimelineNotifications(0, $this->count); + $this->outputStreams($stream); + break; + + case 'liked': + $stream = $this->streamRequest->getTimelineLiked(0, $this->count); $this->outputStreams($stream); break; @@ -175,7 +180,7 @@ class Timeline extends ExtendedBase { default: throw new Exception( - 'Unknown timeline. Try home, direct, local, global, notification.' + 'Unknown timeline. Try home, direct, notifications, liked, local, global.' ); } } diff --git a/lib/Controller/ActivityPubController.php b/lib/Controller/ActivityPubController.php index 8037193f..23713aee 100644 --- a/lib/Controller/ActivityPubController.php +++ b/lib/Controller/ActivityPubController.php @@ -37,6 +37,7 @@ use Exception; use OC\AppFramework\Http; use OCA\Social\AppInfo\Application; use OCA\Social\Exceptions\ItemUnknownException; +use OCA\Social\Exceptions\RealTokenException; use OCA\Social\Exceptions\SignatureIsGoneException; use OCA\Social\Exceptions\SocialAppConfigException; use OCA\Social\Exceptions\StreamNotFoundException; @@ -351,8 +352,14 @@ class ActivityPubController extends Controller { * @return Response * @throws SocialAppConfigException * @throws StreamNotFoundException + * @throws UrlCloudException */ public function displayPost(string $username, string $token): Response { + try { + return $this->fixToken($username, $token); + } catch (RealTokenException $e) { + } + if (!$this->checkSourceActivityStreams()) { return $this->socialPubController->displayPost($username, $token); } @@ -368,6 +375,32 @@ class ActivityPubController extends Controller { /** + * @param string $username + * @param string $token + * + * @return Response + * @throws RealTokenException + * @throws SocialAppConfigException + * @throws UrlCloudException + */ + private function fixToken(string $username, string $token): Response { + $t = strtolower($token); + if ($t === 'outbox') { + return $this->outbox($username); + } + + if ($t === 'followers') { + return $this->followers($username); + } + + if ($t === 'following') { + return $this->following($username); + } + + throw new RealTokenException(); + } + + /** * Check that the request comes from an ActivityPub server, based on the header. * * If not, should forward to a readable webpage that displays content for navigation. diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php index b9f9b1bc..1021d334 100644 --- a/lib/Controller/LocalController.php +++ b/lib/Controller/LocalController.php @@ -400,7 +400,7 @@ class LocalController extends Controller { public function streamNotifications($since = 0, int $limit = 5): DataResponse { try { $this->initViewer(true); - $posts = $this->streamService->getStreamNotifications($this->viewer, $since, $limit); + $posts = $this->streamService->getStreamNotifications($since, $limit); return $this->success($posts); } catch (Exception $e) { diff --git a/lib/Controller/OStatusController.php b/lib/Controller/OStatusController.php index cc012e87..ad848960 100644 --- a/lib/Controller/OStatusController.php +++ b/lib/Controller/OStatusController.php |