diff options
52 files changed, 1743 insertions, 254 deletions
diff --git a/lib/Command/CacheRefresh.php b/lib/Command/CacheRefresh.php index 26a688fe..4990c918 100644 --- a/lib/Command/CacheRefresh.php +++ b/lib/Command/CacheRefresh.php @@ -33,8 +33,8 @@ namespace OCA\Social\Command; use Exception; use OC\Core\Command\Base; -use OCA\Social\Service\ActivityPub\DocumentService; -use OCA\Social\Service\ActivityPub\PersonService; +use OCA\Social\Service\ActivityPub\Object\DocumentService; +use OCA\Social\Service\ActivityPub\Actor\PersonService; use OCA\Social\Service\ActorService; use OCA\Social\Service\ConfigService; use OCA\Social\Service\MiscService; diff --git a/lib/Command/NoteCreate.php b/lib/Command/NoteCreate.php index 307fa4af..1b7da816 100644 --- a/lib/Command/NoteCreate.php +++ b/lib/Command/NoteCreate.php @@ -33,7 +33,7 @@ namespace OCA\Social\Command; use Exception; use OC\Core\Command\Base; use OCA\Social\Model\Post; -use OCA\Social\Service\ActivityPub\NoteService; +use OCA\Social\Service\ActivityPub\Object\NoteService; use OCA\Social\Service\ActivityService; use OCA\Social\Service\ActorService; use OCA\Social\Service\ConfigService; diff --git a/lib/Controller/ActivityPubController.php b/lib/Controller/ActivityPubController.php index b686bf65..0d9f9668 100644 --- a/lib/Controller/ActivityPubController.php +++ b/lib/Controller/ActivityPubController.php @@ -37,14 +37,13 @@ use OCA\Social\AppInfo\Application; use OCA\Social\Db\NotesRequest; use OCA\Social\Exceptions\SignatureIsGoneException; use OCA\Social\Exceptions\UnknownItemException; -use OCA\Social\Service\ActivityPub\FollowService; -use OCA\Social\Service\ActivityPub\PersonService; +use OCA\Social\Service\ActivityPub\Activity\FollowService; +use OCA\Social\Service\ActivityPub\Actor\PersonService; use OCA\Social\Service\ActivityService; use OCA\Social\Service\ActorService; use OCA\Social\Service\ImportService; use OCA\Social\Service\MiscService; use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Http\Response; use OCP\IRequest; diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php index a99782d9..1fa26009 100644 --- a/lib/Controller/LocalController.php +++ b/lib/Controller/LocalController.php @@ -37,12 +37,12 @@ use OCA\Social\AppInfo\Application; use OCA\Social\Exceptions\AccountDoesNotExistException; use OCA\Social\Exceptions\InvalidResourceException; use OCA\Social\Model\ActivityPub\ACore; -use OCA\Social\Model\ActivityPub\Person; +use OCA\Social\Model\ActivityPub\Actor\Person; use OCA\Social\Model\Post; -use OCA\Social\Service\ActivityPub\DocumentService; -use OCA\Social\Service\ActivityPub\FollowService; -use OCA\Social\Service\ActivityPub\NoteService; -use OCA\Social\Service\ActivityPub\PersonService; +use OCA\Social\Service\ActivityPub\Object\DocumentService; +use OCA\Social\Service\ActivityPub\Activity\FollowService; +use OCA\Social\Service\ActivityPub\Object\NoteService; +use OCA\Social\Service\ActivityPub\Actor\PersonService; use OCA\Social\Service\ActorService; use OCA\Social\Service\MiscService; use OCA\Social\Service\PostService; diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php index cbe5a1f1..f3e64c36 100644 --- a/lib/Controller/NavigationController.php +++ b/lib/Controller/NavigationController.php @@ -37,8 +37,8 @@ use OC\User\NoUserException; use OCA\Social\AppInfo\Application; use OCA\Social\Exceptions\AccountAlreadyExistsException; use OCA\Social\Exceptions\SocialAppConfigException; -use OCA\Social\Service\ActivityPub\DocumentService; -use OCA\Social\Service\ActivityPub\PersonService; +use OCA\Social\Service\ActivityPub\Object\DocumentService; +use OCA\Social\Service\ActivityPub\Actor\PersonService; use OCA\Social\Service\ActorService; use OCA\Social\Service\CheckService; use OCA\Social\Service\ConfigService; @@ -227,7 +227,7 @@ class NavigationController extends Controller { $setup = false; try { - $address = $this->configService->getCloudAddress(true); + $this->configService->getCloudAddress(true); $setup = true; } catch (SocialAppConfigException $e) { } diff --git a/lib/Controller/SocialPubController.php b/lib/Controller/SocialPubController.php index efd35049..5654b32d 100644 --- a/lib/Controller/SocialPubController.php +++ b/lib/Controller/SocialPubController.php @@ -34,8 +34,8 @@ use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse; use Exception; use OCA\Social\AppInfo\Application; use OCA\Social\Exceptions\CacheActorDoesNotExistException; -use OCA\Social\Model\ActivityPub\Person; -use OCA\Social\Service\ActivityPub\PersonService; +use OCA\Social\Model\ActivityPub\Actor\Person; +use OCA\Social\Service\ActivityPub\Actor\PersonService; use OCA\Social\Service\ActorService; use OCA\Social\Service\MiscService; use OCP\AppFramework\Controller; diff --git a/lib/Cron/Cache.php b/lib/Cron/Cache.php index df9b741a..087cef31 100644 --- a/lib/Cron/Cache.php +++ b/lib/Cron/Cache.php @@ -34,8 +34,8 @@ namespace OCA\Social\Cron; use Exception; use OC\BackgroundJob\TimedJob; use OCA\Social\AppInfo\Application; -use OCA\Social\Service\ActivityPub\DocumentService; -use OCA\Social\Service\ActivityPub\PersonService; +use OCA\Social\Service\ActivityPub\Object\DocumentService; +use OCA\Social\Service\ActivityPub\Actor\PersonService; use OCA\Social\Service\ActorService; use OCA\Social\Service\ConfigService; use OCA\Social\Service\MiscService; diff --git a/lib/Db/ActorsRequest.php b/lib/Db/ActorsRequest.php index a8ad8a28..be241ab4 100644 --- a/lib/Db/ActorsRequest.php +++ b/lib/Db/ActorsRequest.php @@ -32,7 +32,7 @@ namespace OCA\Social\Db; use OCA\Social\Exceptions\ActorDoesNotExistException; use OCA\Social\Exceptions\SocialAppConfigException; -use OCA\Social\Model\ActivityPub\Person; +use OCA\Social\Model\ActivityPub\Actor\Person; use OCA\Social\Service\ConfigService; use OCA\Social\Service\MiscService; use OCP\IDBConnection; diff --git a/lib/Db/ActorsRequestBuilder.php b/lib/Db/ActorsRequestBuilder.php index 0312dea3..5263c6e3 100644 --- a/lib/Db/ActorsRequestBuilder.php +++ b/lib/Db/ActorsRequestBuilder.php @@ -32,7 +32,7 @@ namespace OCA\Social\Db; use daita\MySmallPhpTools\Traits\TArrayTools; use OCA\Social\Exceptions\SocialAppConfigException; -use OCA\Social\Model\ActivityPub\Person; +use OCA\Social\Model\ActivityPub\Actor\Person; use OCP\DB\QueryBuilder\IQueryBuilder; class ActorsRequestBuilder extends CoreRequestBuilder { diff --git a/lib/Db/CacheActorsRequest.php b/lib/Db/CacheActorsRequest.php index e69afbc1..6298c12b 100644 --- a/lib/Db/CacheActorsRequest.php +++ b/lib/Db/CacheActorsRequest.php @@ -33,7 +33,7 @@ namespace OCA\Social\Db; use DateTime; use Exception; use OCA\Social\Exceptions\CacheActorDoesNotExistException; -use OCA\Social\Model\ActivityPub\Person; +use OCA\Social\Model\ActivityPub\Actor\Person; use OCA\Social\Service\ConfigService; use OCA\Social\Service\MiscService; use OCP\DB\QueryBuilder\IQueryBuilder; diff --git a/lib/Db/CacheActorsRequestBuilder.php b/lib/Db/CacheActorsRequestBuilder.php index 4833d0e9..fe0e5313 100644 --- a/lib/Db/CacheActorsRequestBuilder.php +++ b/lib/Db/CacheActorsRequestBuilder.php @@ -32,7 +32,7 @@ namespace OCA\Social\Db; use daita\MySmallPhpTools\Traits\TArrayTools; use OCA\Social\Exceptions\InvalidResourceException; -use OCA\Social\Model\ActivityPub\Person; +use OCA\Social\Model\ActivityPub\Actor\Person; use OCP\DB\QueryBuilder\IQueryBuilder; class CacheActorsRequestBuilder extends CoreRequestBuilder { diff --git a/lib/Db/CacheDocumentsRequest.php b/lib/Db/CacheDocumentsRequest.php index 3b5d917a..43b9ad3e 100644 --- a/lib/Db/CacheDocumentsRequest.php +++ b/lib/Db/CacheDocumentsRequest.php @@ -33,7 +33,7 @@ namespace OCA\Social\Db; use DateTime; use Exception; use OCA\Social\Exceptions\CacheDocumentDoesNotExistException; -use OCA\Social\Model\ActivityPub\Document; +use OCA\Social\Model\ActivityPub\Object\Document; use OCP\DB\QueryBuilder\IQueryBuilder; class CacheDocumentsRequest extends CacheDocumentsRequestBuilder { diff --git a/lib/Db/CacheDocumentsRequestBuilder.php b/lib/Db/CacheDocumentsRequestBuilder.php index 4271fe6d..300f5066 100644 --- a/lib/Db/CacheDocumentsRequestBuilder.php +++ b/lib/Db/CacheDocumentsRequestBuilder.php @@ -31,8 +31,7 @@ namespace OCA\Social\Db; use daita\MySmallPhpTools\Traits\TArrayTools; -use OCA\Social\Model\ActivityPub\Document; -use OCA\Social\Model\ActivityPub\Image; +use OCA\Social\Model\ActivityPub\Object\Document; use OCP\DB\QueryBuilder\IQueryBuilder; class CacheDocumentsRequestBuilder extends CoreRequestBuilder { diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 8f594ddd..1e96b620 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -36,10 +36,10 @@ use DateTime; use Doctrine\DBAL\Query\QueryBuilder; use Exception; use OCA\Social\Exceptions\InvalidResourceException; -use OCA\Social\Model\ActivityPub\Document; -use OCA\Social\Model\ActivityPub\Follow; -use OCA\Social\Model\ActivityPub\Image; -use OCA\Social\Model\ActivityPub\Person; +use OCA\Social\Model\ActivityPub\Object\Document; +use OCA\Social\Model\ActivityPub\Activity\Follow; +use OCA\Social\Model\ActivityPub\Object\Image; +use OCA\Social\Model\ActivityPub\Actor\Person; use OCA\Social\Service\ConfigService; use OCA\Social\Service\MiscService; use OCP\DB\QueryBuilder\IQueryBuilder; diff --git a/lib/Db/FollowsRequest.php b/lib/Db/FollowsRequest.php index fac47cdb..eb8789ed 100644 --- a/lib/Db/FollowsRequest.php +++ b/lib/Db/FollowsRequest.php @@ -34,8 +34,7 @@ namespace OCA\Social\Db; use daita\MySmallPhpTools\Traits\TArrayTools; use DateTime; use OCA\Social\Exceptions\FollowDoesNotExistException; -use OCA\Social\Exceptions\InvalidResourceException; -use OCA\Social\Model\ActivityPub\Follow; +use OCA\Social\Model\ActivityPub\Activity\Follow; use OCP\DB\QueryBuilder\IQueryBuilder; diff --git a/lib/Db/FollowsRequestBuilder.php b/lib/Db/FollowsRequestBuilder.php index 01e08442..6fb323a6 100644 --- a/lib/Db/FollowsRequestBuilder.php +++ b/lib/Db/FollowsRequestBuilder.php @@ -33,7 +33,7 @@ namespace OCA\Social\Db; use daita\MySmallPhpTools\Traits\TArrayTools; use OCA\Social\Exceptions\InvalidResourceException; -use OCA\Social\Model\ActivityPub\Follow; +use OCA\Social\Model\ActivityPub\Activity\Follow; use OCP\DB\QueryBuilder\IQueryBuilder; diff --git a/lib/Db/NotesRequest.php b/lib/Db/NotesRequest.php index fdd1313b..fa2f77b2 100644 --- a/lib/Db/NotesRequest.php +++ b/lib/Db/NotesRequest.php @@ -32,8 +32,8 @@ namespace OCA\Social\Db; use DateTime; use OCA\Social\Exceptions\NoteNotFoundException; -use OCA\Social\Model\ActivityPub\Note; -use OCA\Social\Model\ActivityPub\Person; +use OCA\Social\Model\ActivityPub\Object\Note; +use OCA\Social\Model\ActivityPub\Actor\Person; use OCA\Social\Service\ActivityService; use OCA\Social\Service\ConfigService; use OCA\Social\Service\MiscService; diff --git a/lib/Db/NotesRequestBuilder.php b/lib/Db/NotesRequestBuilder.php index 872004fa..4adaf37a 100644 --- a/lib/Db/NotesRequestBuilder.php +++ b/lib/Db/NotesRequestBuilder.php @@ -34,8 +34,8 @@ use daita\MySmallPhpTools\Traits\TArrayTools; use DateTime; use Doctrine\DBAL\Query\QueryBuilder; use OCA\Social\Exceptions\InvalidResourceException; -use OCA\Social\Model\ActivityPub\Note; -use OCA\Social\Model\ActivityPub\Person; +use OCA\Social\Model\ActivityPub\Object\Note; +use OCA\Social\Model\ActivityPub\Actor\Person; use OCA\Social\Model\InstancePath; use OCP\DB\QueryBuilder\ICompositeExpression; use OCP\DB\QueryBuilder\IQueryBuilder; diff --git a/lib/Model/ActivityPub/ACore.php b/lib/Model/ActivityPub/ACore.php index 3e76e2fc..c0b8ccf3 100644 --- a/lib/Model/ActivityPub/ACore.php +++ b/lib/Model/ActivityPub/ACore.php @@ -37,6 +37,7 @@ use OCA\Social\Exceptions\ActivityCantBeVerifiedException; use OCA\Social\Exceptions\InvalidOriginException; use OCA\Social\Exceptions\InvalidResourceEntryException; use OCA\Social\Exceptions\UrlCloudException; +use OCA\Social\Model\ActivityPub\Object\Document; use OCA\Social\Service\ActivityPub\ICoreService; @@ -87,18 +88,18 @@ abstract class ACore extends Item implements JsonSerializable { /** - * @param Item $parent + * @param ACore $parent * - * @return Item + * @return ACore */ - public function setParent(Item $parent): ACore { + public function setParent(ACore $parent): ACore { $this->parent = $parent; return $this; } /** - * @return Item + * @return ACore */ public function getParent(): ACore { return $this->parent; @@ -384,13 +385,13 @@ abstract class ACore extends Item implements JsonSerializable { * @param string $default * * @return string - * @throws InvalidResourceEntryException */ public function validate(int $as, string $k, array $arr, string $default = ''): string { - $value = $this->validateEntryString($as, $this->get($k, $arr, $default)); - - - return $value; + try { + return $this->validateEntryString($as, $this->get($k, $arr, $default)); + } catch (InvalidResourceEntryException $e) { + return $default; + } } @@ -401,14 +402,16 @@ abstract class ACore extends Item implements JsonSerializable { * @param array $default * * @return array - * @throws InvalidResourceEntryException */ public function validateArray(int $as, string $k, array $arr, array $default = []): array { $values = $this->getArray($k, $arr, $default); $result = []; foreach ($values as $value) { - $result[] = $this->validateEntryString($as, $value); + try { + $result[] = $this->validateEntryString($as, $value); + } catch (InvalidResourceEntryException $e) { + } } return $result; @@ -469,8 +472,6 @@ abstract class ACore extends Item implements JsonSerializable { /** * @param array $data - * - * @throws InvalidResourceEntryException */ public function import(array $data) { $this->setId($this->validate(self::AS_ID, 'id', $data, '')); diff --git a/lib/Model/ActivityPub/Activity/Add.php b/lib/Model/ActivityPub/Activity/Add.php new file mode 100644 index 00000000..321913eb --- /dev/null +++ b/lib/Model/ActivityPub/Activity/Add.php @@ -0,0 +1,81 @@ +<?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\Model\ActivityPub\Activity; + + +use JsonSerializable; +use OCA\Social\Model\ActivityPub\ACore; + + +/** + * Class Add + * + * @package OCA\Social\Model\ActivityPub\Activity + */ +class Add extends ACore implements JsonSerializable { + + + const TYPE = 'Add'; + + + /** + * Activity constructor. + * + * @param ACore $parent + */ + public function __construct($parent = null) { + parent::__construct($parent); + + $this->setType(self::TYPE); + } + + + /** + * @param array $data + */ + public function import(array $data) { + parent::import($data); + } + + + /** + * @return array + */ + public function jsonSerialize(): array { + return array_merge( + parent::jsonSerialize(), + [ + ] + ); + } + +} + diff --git a/lib/Model/ActivityPub/Activity/Block.php b/lib/Model/ActivityPub/Activity/Block.php new file mode 100644 index 00000000..2245ff88 --- /dev/null +++ b/lib/Model/ActivityPub/Activity/Block.php @@ -0,0 +1,81 @@ +<?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 + * MERC |