From 3cec05e7f8f20480ad8f1251edbdb8e0c32e9688 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Mon, 19 Nov 2018 09:33:34 -0100 Subject: [PATCH] moving thing around Signed-off-by: Maxence Lange --- lib/Model/ActivityPub/Activity/Accept.php | 82 +++++++++++++++++++ .../{Activity.php => Activity/Create.php} | 23 ++++-- lib/Model/ActivityPub/Activity/Reject.php | 82 +++++++++++++++++++ lib/Model/ActivityPub/{ => Activity}/Undo.php | 20 ++--- 4 files changed, 190 insertions(+), 17 deletions(-) create mode 100644 lib/Model/ActivityPub/Activity/Accept.php rename lib/Model/ActivityPub/{Activity.php => Activity/Create.php} (78%) create mode 100644 lib/Model/ActivityPub/Activity/Reject.php rename lib/Model/ActivityPub/{ => Activity}/Undo.php (81%) diff --git a/lib/Model/ActivityPub/Activity/Accept.php b/lib/Model/ActivityPub/Activity/Accept.php new file mode 100644 index 00000000..9d310c2d --- /dev/null +++ b/lib/Model/ActivityPub/Activity/Accept.php @@ -0,0 +1,82 @@ + + * @copyright 2018, Maxence Lange + * @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 . + * + */ + + +namespace OCA\Social\Model\ActivityPub\Activity; + + +use JsonSerializable; +use OCA\Social\Model\ActivityPub\ACore; + + +/** + * Class Accept + * + * @package OCA\Social\Model\ActivityPub\Activity + */ +class Accept extends ACore implements JsonSerializable { + + + const TYPE = 'Accept'; + + + + /** + * Undo 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.php b/lib/Model/ActivityPub/Activity/Create.php similarity index 78% rename from lib/Model/ActivityPub/Activity.php rename to lib/Model/ActivityPub/Activity/Create.php index c5c0306d..690e3d07 100644 --- a/lib/Model/ActivityPub/Activity.php +++ b/lib/Model/ActivityPub/Activity/Create.php @@ -27,23 +27,34 @@ declare(strict_types=1); * */ -namespace OCA\Social\Model\ActivityPub; + +namespace OCA\Social\Model\ActivityPub\Activity; use JsonSerializable; +use OCA\Social\Model\ActivityPub\ACore; -class Activity extends ACore implements JsonSerializable { + +/** + * Class Create + * + * @package OCA\Social\Model\ActivityPub\Activity + */ +class Create extends ACore implements JsonSerializable { + + + const TYPE = 'Create'; /** * Activity constructor. * - * @param bool $isTopLevel + * @param ACore $parent */ - public function __construct(bool $isTopLevel = false) { - parent::__construct($isTopLevel); + public function __construct($parent = null) { + parent::__construct($parent); - $this->setType('Create'); + $this->setType(self::TYPE); } diff --git a/lib/Model/ActivityPub/Activity/Reject.php b/lib/Model/ActivityPub/Activity/Reject.php new file mode 100644 index 00000000..5ceb2808 --- /dev/null +++ b/lib/Model/ActivityPub/Activity/Reject.php @@ -0,0 +1,82 @@ + + * @copyright 2018, Maxence Lange + * @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 . + * + */ + + +namespace OCA\Social\Model\ActivityPub\Activity; + + +use JsonSerializable; +use OCA\Social\Model\ActivityPub\ACore; + + +/** + * Class Reject + * + * @package OCA\Social\Model\ActivityPub\Activity + */ +class Reject extends ACore implements JsonSerializable { + + + const TYPE = 'Reject'; + + + + /** + * Undo 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/Undo.php b/lib/Model/ActivityPub/Activity/Undo.php similarity index 81% rename from lib/Model/ActivityPub/Undo.php rename to lib/Model/ActivityPub/Activity/Undo.php index 4fe7ba48..3b3e096c 100644 --- a/lib/Model/ActivityPub/Undo.php +++ b/lib/Model/ActivityPub/Activity/Undo.php @@ -28,36 +28,34 @@ declare(strict_types=1); */ -namespace OCA\Social\Model\ActivityPub; +namespace OCA\Social\Model\ActivityPub\Activity; use JsonSerializable; +use OCA\Social\Model\ActivityPub\ACore; /** * Class Undo * - * @package OCA\Social\Model\ActivityPub + * @package OCA\Social\Model\ActivityPub\Activity */ class Undo extends ACore implements JsonSerializable { - private $actor; + const TYPE = 'Undo'; - private $object; - /** - * Activity constructor. + * Undo constructor. * - * @param bool $isTopLevel + * @param ACore $parent */ - public function __construct(bool $isTopLevel = false) { - parent::__construct($isTopLevel); + public function __construct($parent = null) { + parent::__construct($parent); - $this->setType('Undo'); - $this->addMetaBool('Undo', true); + $this->setType(self::TYPE); }