summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2018-12-16 21:53:00 -0100
committerMaxence Lange <maxence@artificial-owl.com>2018-12-16 21:53:00 -0100
commit76775ddf2882bc0d6af1b4e0adc460c826efc38f (patch)
treef064285a9afe6133bf50317b73b23a1fb0467505 /lib
parent7f2eede76bf40ba2c60deb10b9356ca9e8864889 (diff)
static AP + interfaces
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/AP.php363
-rw-r--r--lib/Exceptions/ItemNotFoundException.php8
-rw-r--r--lib/Exceptions/RedundancyLimitException.php8
-rw-r--r--lib/Interfaces/Activity/AcceptInterface.php (renamed from lib/Service/ActivityPub/Activity/AcceptService.php)28
-rw-r--r--lib/Interfaces/Activity/AddInterface.php (renamed from lib/Service/ActivityPub/Activity/AddService.php)26
-rw-r--r--lib/Interfaces/Activity/BlockInterface.php (renamed from lib/Service/ActivityPub/Activity/BlockService.php)26
-rw-r--r--lib/Interfaces/Activity/CreateInterface.php114
-rw-r--r--lib/Interfaces/Activity/DeleteInterface.php148
-rw-r--r--lib/Interfaces/Activity/FollowInterface.php (renamed from lib/Service/ActivityPub/Activity/FollowService.php)194
-rw-r--r--lib/Interfaces/Activity/LikeInterface.php (renamed from lib/Service/ActivityPub/Activity/LikeService.php)28
-rw-r--r--lib/Interfaces/Activity/RejectInterface.php (renamed from lib/Service/ActivityPub/Activity/RejectService.php)27
-rw-r--r--lib/Interfaces/Activity/RemoveInterface.php (renamed from lib/Service/ActivityPub/Activity/RemoveService.php)27
-rw-r--r--lib/Interfaces/Activity/UndoInterface.php (renamed from lib/Service/ActivityPub/Activity/UndoService.php)26
-rw-r--r--lib/Interfaces/Activity/UpdateInterface.php (renamed from lib/Service/ActivityPub/Activity/UpdateService.php)28
-rw-r--r--lib/Interfaces/Actor/PersonInterface.php142
-rw-r--r--lib/Interfaces/IActivityPubInterface.php (renamed from lib/Service/ActivityPub/ICoreService.php)21
-rw-r--r--lib/Interfaces/Object/DocumentInterface.php244
-rw-r--r--lib/Interfaces/Object/NoteInterface.php147
-rw-r--r--lib/Model/ActivityPub/ACore.php32
-rw-r--r--lib/Service/AccountService.php (renamed from lib/Service/ActorService.php)43
-rw-r--r--lib/Service/ActivityPub/Activity/CreateService.php104
-rw-r--r--lib/Service/ActivityPub/Activity/DeleteService.php132
-rw-r--r--lib/Service/ActivityPub/Actor/PersonService.php357
-rw-r--r--lib/Service/ActivityPub/Object/DocumentService.php278
-rw-r--r--lib/Service/ActivityPub/Object/NoteService.php431
-rw-r--r--lib/Service/CacheDocumentService.php (renamed from lib/Service/CacheService.php)0
26 files changed, 1395 insertions, 1587 deletions
diff --git a/lib/AP.php b/lib/AP.php
new file mode 100644
index 00000000..705dafe2
--- /dev/null
+++ b/lib/AP.php
@@ -0,0 +1,363 @@
+<?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 daita\MySmallPhpTools\Traits\TArrayTools;
+use OCA\Social\Exceptions\RedundancyLimitException;
+use OCA\Social\Exceptions\SocialAppConfigException;
+use OCA\Social\Exceptions\UnknownItemException;
+use OCA\Social\Interfaces\Activity\AcceptInterface;
+use OCA\Social\Interfaces\Activity\AddInterface;
+use OCA\Social\Interfaces\Activity\BlockInterface;
+use OCA\Social\Interfaces\Activity\CreateInterface;
+use OCA\Social\Interfaces\Activity\DeleteInterface;
+use OCA\Social\Interfaces\Activity\FollowInterface;
+use OCA\Social\Interfaces\Activity\LikeInterface;
+use OCA\Social\Interfaces\Activity\RejectInterface;
+use OCA\Social\Interfaces\Activity\RemoveInterface;
+use OCA\Social\Interfaces\Activity\UndoInterface;
+use OCA\Social\Interfaces\Activity\UpdateInterface;
+use OCA\Social\Interfaces\Actor\PersonInterface;
+use OCA\Social\Interfaces\IActivityPubInterface;
+use OCA\Social\Interfaces\Object\NoteInterface;
+use OCA\Social\Model\ActivityPub\ACore;
+use OCA\Social\Model\ActivityPub\Activity\Accept;
+use OCA\Social\Model\ActivityPub\Activity\Add;
+use OCA\Social\Model\ActivityPub\Activity\Block;
+use OCA\Social\Model\ActivityPub\Activity\Create;
+use OCA\Social\Model\ActivityPub\Activity\Delete;
+use OCA\Social\Model\ActivityPub\Activity\Follow;
+use OCA\Social\Model\ActivityPub\Activity\Like;
+use OCA\Social\Model\ActivityPub\Activity\Reject;
+use OCA\Social\Model\ActivityPub\Activity\Remove;
+use OCA\Social\Model\ActivityPub\Activity\Undo;
+use OCA\Social\Model\ActivityPub\Activity\Update;
+use OCA\Social\Model\ActivityPub\Actor\Person;
+use OCA\Social\Model\ActivityPub\Object\Document;
+use OCA\Social\Model\ActivityPub\Object\Image;
+use OCA\Social\Model\ActivityPub\Object\Note;
+use OCA\Social\Model\ActivityPub\Object\Tombstone;
+use OCA\Social\Service\ConfigService;
+use OCP\AppFramework\QueryException;
+
+
+/**
+ * Class AP
+ *
+ * @package OCA\Social
+ */
+class AP {
+
+
+ use TArrayTools;
+
+
+ const REDUNDANCY_LIMIT = 10;
+
+
+ /** @var AcceptInterface */
+ public $acceptInterface;
+
+ /** @var AddInterface */
+ public $addInterface;
+
+ /** @var BlockInterface */
+ public $blockInterface;
+
+ /** @var CreateInterface */
+ public $createInterface;
+
+ /** @var DeleteInterface */
+ public $deleteInterface;
+
+ /** @var FollowInterface */
+ public $followInterface;
+
+ /** @var LikeInterface */
+ public $likeInterface;
+
+ /** @var PersonInterface */
+ public $personInterface;
+
+ /** @var NoteInterface */
+ public $noteInterface;
+
+ /** @var RejectInterface */
+ public $rejectInterface;
+
+ /** @var RemoveInterface */
+ public $removeInterface;
+
+ /** @var UndoInterface */
+ public $undoInterface;
+
+ /** @var UpdateInterface */
+ public $updateInterface;
+
+ /** @var ConfigService */
+ public $configService;
+
+
+ /** @var AP */
+ public static $activityPub = null;
+
+
+ /**
+ * AP constructor.
+ */
+ public function __construct() {
+ }
+
+
+ /**
+ *
+ */
+ public static function init() {
+ $ap = new AP();
+ try {
+ $ap->acceptInterface = \OC::$server->query(AcceptInterface::class);
+ $ap->addInterface = \OC::$server->query(AddInterface::class);
+ $ap->blockInterface = \OC::$server->query(BlockInterface::class);
+ $ap->createInterface = \OC::$server->query(CreateInterface::class);
+ $ap->deleteInterface = \OC::$server->query(DeleteInterface::class);
+ $ap->followInterface = \OC::$server->query(FollowInterface::class);
+ $ap->likeInterface = \OC::$server->query(LikeInterface::class);
+ $ap->rejectInterface = \OC::$server->query(RejectInterface::class);
+ $ap->removeInterface = \OC::$server->query(RemoveInterface::class);
+ $ap->personInterface = \OC::$server->query(PersonInterface::class);
+ $ap->noteInterface = \OC::$server->query(NoteInterface::class);
+ $ap->undoInterface = \OC::$server->query(UndoInterface::class);
+ $ap->updateInterface = \OC::$server->query(UpdateInterface::class);
+
+ $ap->configService = \OC::$server->query(ConfigService::class);
+
+ AP::$activityPub = $ap;
+ } catch (QueryException $e) {
+ }
+ }
+
+
+ /**
+ * @param array $data
+ * @param ACore $parent
+ * @param int $level
+ *
+ * @return ACore
+ * @throws RedundancyLimitException
+ * @throws SocialAppConfigException
+ * @throws UnknownItemException
+ */
+ public function getItemFromData(array $data, $parent = null, int $level = 0): ACore {
+ if (++$level > self::REDUNDANCY_LIMIT) {
+ throw new RedundancyLimitException($level);
+ }
+
+ $item = $this->getSimpleItemFromData($data);
+ if ($parent !== null) {
+ $item->setParent($parent);
+ }
+
+ try {
+ $object = $this->getItemFromData($this->getArray('object', $data, []), $item, $level);
+ $item->setObject($object);
+ } catch (UnknownItemException $e) {
+ }
+
+ try {
+ /** @var Document $icon */
+ $icon = $this->getItemFromData($this->getArray('icon', $data, []), $item, $level);
+ $item->setIcon($icon);
+ } catch (UnknownItemException $e) {
+ }
+
+ return $item;
+ }
+
+
+ /**
+ * @param array $data
+ *
+ * @return ACore
+ * @throws SocialAppConfigException
+ * @throws UnknownItemException
+ */
+ public function getSimpleItemFromData(array $data): Acore {
+ $item = $this->getItemFromType($this->get('type', $data, ''));
+ $item->setUrlCloud($this->configService->getCloudAddress());
+ $item->import($data);
+ $item->setSource(json_encode($data, JSON_UNESCAPED_SLASHES));
+
+ return $item;
+ }
+
+ /**
+ * @param string $type
+ *
+ * @return ACore
+ * @throws UnknownItemException
+ */
+ public function getItemFromType(string $type) {
+ switch ($type) {
+ case Accept::TYPE:
+ return new Accept();
+
+ case Add::TYPE:
+ return new Add();
+
+ case Block::TYPE:
+ return new Block();
+
+ case Create::TYPE:
+ return new Create();
+
+ case Delete::TYPE:
+ return new Delete();
+
+ case Follow::TYPE:
+ return new Follow();
+
+ case Image::TYPE:
+ return new Image();
+
+ case Like::TYPE:
+ return new Like();
+
+ case Note::TYPE:
+ return new Note();
+
+ case Person::TYPE:
+ return new Note();
+
+ case Reject::TYPE:
+ return new Reject();
+
+ case Remove::TYPE:
+ return new Remove();
+
+ case Tombstone::TYPE:
+ return new Tombstone();
+
+ case Undo::TYPE:
+ return new Undo();
+
+ case Update::TYPE:
+ return new Update();
+
+ default:
+ throw new UnknownItemException();
+ }
+ }
+
+
+ /**
+ * @param ACore $activity
+ *
+ * @return IActivityPubInterface
+ * @throws UnknownItemException
+ */
+ public function getInterfaceForItem(Acore $activity): IActivityPubInterface {
+ return $this->getInterfaceFromType($activity->getType());
+ }
+
+
+ /**
+ * @param string $type
+ *
+ * @return IActivityPubInterface
+ * @throws UnknownItemException
+ */
+ public function getInterfaceFromType(string $type): IActivityPubInterface {
+ switch ($type) {
+ case Accept::TYPE:
+ $service = $this->acceptInterface;
+ break;
+
+ case Add::TYPE:
+ $service = $this->addInterface;
+ break;
+
+ case Block::TYPE:
+ $service = $this->blockInterface;
+ break;
+
+ case Create::TYPE:
+ $service = $this->createInterface;
+ break;
+
+ case Delete::TYPE:
+ $service = $this->deleteInterface;
+ break;
+
+ case Follow::TYPE:
+ $service = $this->followInterface;
+ break;
+
+ case Like::TYPE:
+ $service = $this->likeInterface;
+ break;
+
+ case Note::TYPE:
+ $service = $this->noteInterface;
+ break;
+
+ case Person::TYPE:
+ $service = $this->personInterface;
+ break;
+
+ case Reject::TYPE:
+ $service = $this->rejectInterface;
+ break;
+
+ case Remove::TYPE:
+ $service = $this->removeInterface;
+ break;
+
+ case Undo::TYPE:
+ $service = $this->undoInterface;
+ break;
+
+ case Update::TYPE:
+ $service = $this->updateInterface;
+ break;
+
+ default:
+ throw new UnknownItemException();
+ }
+
+ return $service;
+ }
+
+}
+
+
+AP::init();
+
diff --git a/lib/Exceptions/ItemNotFoundException.php b/lib/Exceptions/ItemNotFoundException.php
new file mode 100644
index 00000000..60b90bf1
--- /dev/null
+++ b/lib/Exceptions/ItemNotFoundException.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace OCA\Social\Exceptions;
+
+class ItemNotFoundException extends \Exception {
+
+}
+
diff --git a/lib/Exceptions/RedundancyLimitException.php b/lib/Exceptions/RedundancyLimitException.php
new file mode 100644
index 00000000..7a28a908
--- /dev/null
+++ b/lib/Exceptions/RedundancyLimitException.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace OCA\Social\Exceptions;
+
+class RedundancyLimitException extends \Exception {
+
+}
+
diff --git a/lib/Service/ActivityPub/Activity/AcceptService.php b/lib/Interfaces/Activity/AcceptInterface.php
index bbdfb2aa..d2addb8e 100644
--- a/lib/Service/ActivityPub/Activity/AcceptService.php
+++ b/lib/Interfaces/Activity/AcceptInterface.php
@@ -28,17 +28,18 @@ declare(strict_types=1);
*/
-namespace OCA\Social\Service\ActivityPub\Activity;
+namespace OCA\Social\Interfaces\Activity;
+use OCA\Social\AP;
+use OCA\Social\Exceptions\ItemNotFoundException;
use OCA\Social\Exceptions\UnknownItemException;
+use OCA\Social\Interfaces\IActivityPubInterface;
use OCA\Social\Model\ActivityPub\ACore;
-use OCA\Social\Service\ActivityPub\ICoreService;
-use OCA\Social\Service\ImportService;
use OCA\Social\Service\MiscService;
-class AcceptService implements ICoreService {
+class AcceptInterface implements IActivityPubInterface {
/** @var MiscService */
@@ -57,16 +58,15 @@ class AcceptService implements ICoreService {
/**
* @param ACore $item
- * @param ImportService $importService
*/
- public function processIncomingRequest(ACore $item, ImportService $importService) {
+ public function processIncomingRequest(ACore $item) {
if (!$item->gotObject()) {
return;
}
$object = $item->getObject();
try {
- $service = $importService->getServiceForItem($item->getObject());
+ $service = AP::$activityPub->getInterfaceForItem($item->getObject());
$service->activity($item, $object);
} catch (UnknownItemException $e) {
}
@@ -75,12 +75,21 @@ class AcceptService implements ICoreService {
/**
* @param ACore $item
- * @param ImportService $importService
*/
- public function processResult(ACore $item, ImportService $importService) {
+ public function processResult(ACore $item) {
}
+ /**
+ * @param string $id
+ *
+ * @return ACore
+ * @throws ItemNotFoundException
+ */
+ public function getItemById(string $id): ACore {
+ throw new ItemNotFoundException();
+ }
+
/**
* @param ACore $item
@@ -101,5 +110,6 @@ class AcceptService implements ICoreService {
*/
public function activity(ACore $activity, ACore $item) {
}
+
}
diff --git a/lib/Service/ActivityPub/Activity/AddService.php b/lib/Interfaces/Activity/AddInterface.php
index 166e2b80..efd0adce 100644
--- a/lib/Service/ActivityPub/Activity/AddService.php
+++ b/lib/Interfaces/Activity/AddInterface.php
@@ -28,17 +28,18 @@ declare(strict_types=1);
*/
-namespace OCA\Social\Service\ActivityPub\Activity;
+namespace OCA\Social\Interfaces\Activity;
+use OCA\Social\AP;
+use OCA\Social\Exceptions\ItemNotFoundException;
use OCA\Social\Exceptions\UnknownItemException;
+use OCA\Social\Interfaces\IActivityPubInterface;
use OCA\Social\Model\ActivityPub\ACore;
-use OCA\Social\Service\ActivityPub\ICoreService;
-use OCA\Social\Service\ImportService;
use OCA\Social\Service\MiscService;
-class AddService implements ICoreService {
+class AddInterface implements IActivityPubInterface {
/** @var MiscService */
@@ -57,16 +58,15 @@ class AddService implements ICoreService {
/**
* @param ACore $item
- * @param ImportService $importService
*/
- public function processIncomingRequest(ACore $item, ImportService $importService) {
+ public function processIncomingRequest(ACore $item) {
if (!$item->gotObject()) {
return;
}
$object = $item->getObject();
try {
- $service = $importService->getServiceForItem($item->getObject());
+ $service = AP::$activityPub->getInterfaceForItem($item->getObject());
$service->activity($item, $object);
} catch (UnknownItemException $e) {
}
@@ -75,12 +75,20 @@ class AddService implements ICoreService {
/**
* @param ACore $item
- * @param ImportService $importService
*/
- public function processResult(ACore $item, ImportService $importService) {
+ public function processResult(ACore $item) {
}
+ /**
+ * @param string $id
+ *
+ * @return ACore
+ * @throws ItemNotFoundException
+ */
+ public function getItemById(string $id): ACore {
+ throw new ItemNotFoundException();
+ }
/**
diff --git a/lib/Service/ActivityPub/Activity/BlockService.php b/lib/Interfaces/Activity/BlockInterface.php
index 35c58e3f..cec96640 100644
--- a/lib/Service/ActivityPub/Activity/BlockService.php
+++ b/lib/Interfaces/Activity/BlockInterface.php
@@ -28,17 +28,18 @@ declare(strict_types=1);
*/
-namespace OCA\Social\Service\ActivityPub\Activity;
+namespace OCA\Social\Interfaces\Activity;
+use OCA\Social\AP;
+use OCA\Social\Exceptions\ItemNotFoundException;
use OCA\Social\Exceptions\UnknownItemException;
+use OCA\Social\Interfaces\IActivityPubInterface;
use OCA\Social\Model\ActivityPub\ACore;
-use OCA\Social\Service\ActivityPub\ICoreService;
-use OCA\Social\Service\ImportService;
use OCA\Social\Service\MiscService;
-class BlockService implements ICoreService {
+class BlockInterface implements IActivityPubInterface {
/** @var MiscService */
@@ -57,16 +58,15 @@ class BlockService implements ICoreService {
/**
* @param ACore $item
- * @param ImportService $importService
*/
- public function processIncomingRequest(ACore $item, ImportService $importService) {
+ public function processIncomingRequest(ACore $item) {
if (!$item->gotObject()) {
return;
}
$object = $item->getObject();
try {
- $service = $importService->getServiceForItem($item->getObject());
+ $service = AP::$activityPub->getInterfaceForItem($item->getObject());
$service->activity($item, $object);
} catch (UnknownItemException $e) {
}
@@ -75,12 +75,20 @@ class BlockService implements ICoreService {
/**
* @param ACore $item
- * @param ImportService $importService
*/
- public function processResult(ACore $item, ImportService $importService) {
+ public function processResult(ACore $item) {
}
+ /**
+ * @param string $id
+ *
+ * @return ACore
+ * @throws ItemNotFoundException
+ */
+ public function getItemById(string $id): ACore {
+ throw new ItemNotFoundException();
+ }
/**
diff --git a/lib/Interfaces/Activity/CreateInterface.php b/lib/Interfaces/Activity/CreateInterface.php
new file mode 100644
index 00000000..966fa931
--- /dev/null
+++ b/lib/Interfaces/Activity/CreateInterface.php
@@ -0,0 +1,114 @@
+<?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\Interfaces\Activity;
+
+
+use OCA\Social\AP;
+use OCA\Social\Exceptions\ItemNotFoundException;
+use OCA\Social\Exceptions\UnknownItemException;
+use OCA\Social\Interfaces\IActivityPubInterface;
+use OCA\Social\Model\ActivityPub\ACore;
+use OCA\Social\Service\MiscService;
+
+
+class CreateInterface implements IActivityPubInterface {
+
+
+ /** @var MiscService */
+ private $miscService;
+
+
+ /**
+ * CreateInterface constructor.
+ *
+ * @param MiscService $miscService
+ */
+ public function __construct(MiscService $miscService) {
+ $this->miscService = $miscService;
+ }
+
+
+ /**
+ * @param ACore $item
+ */
+ public function processIncomingRequest(ACore $item) {
+ if (!$item->gotObject()) {
+ return;
+ }
+ $object = $item->getObject();
+
+ try {
+ $service = AP::$activityPub->getInterfaceForItem($item->getObject());
+ $service->activity($item, $object);
+ } catch (UnknownItemException $e) {
+ }
+ }
+
+
+ /**
+ * @param ACore $item
+ */
+ public function processResult(ACore $item) {
+ }
+
+
+ /**
+ * @param string $id
+ *
+ * @return ACore
+ * @throws ItemNotFoundException
+ */
+ public function getItemById(string $id): ACore {
+ throw new ItemNotFoundException();
+ }
+
+
+ /**
+ * @param ACore $item
+ */
+ public function save(ACore $item) {
+ }
+
+
+ /**
+ * @param ACore $item
+ */
+ public function delete(ACore $item) {
+ }
+
+ /**
+ * @param ACore $activity
+ * @param ACore $item
+ */
+ public function activity(ACore $activity, ACore $item) {
+ }
+}
+
diff --git a/lib/Interfaces/Activity/DeleteInterface.php b/lib/Interfaces/Activity/DeleteInterface.php
new file mode 100644
index 00000000..abe5a815
--- /dev/null
+++ b/lib/Interfaces/Activity/DeleteInterface.php
@@ -0,0 +1,148 @@
+<?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\Interfaces\Activity;
+
+
+use OCA\Social\AP;
+use OCA\Social\Exceptions\ItemNotFoundException;
+use OCA\Social\Exceptions\UnknownItemException;
+use OCA\Social\Interfaces\IActivityPubInterface;
+use OCA\Social\Model\ActivityPub\ACore;
+use OCA\Social\Service\MiscService;
+
+class DeleteInterface implements IActivityPubInterface {
+
+
+ /** @var MiscService */
+ private $miscService;
+
+
+ /**
+ * UndoService constructor.
+ *
+ * @param MiscService $miscService
+ */
+ public function __construct(MiscService $miscService) {
+ $this->miscService = $miscService;
+ }
+
+
+ /**
+ * @param ACore $item
+ *
+ */
+ public function processIncomingRequest(ACore $item) {
+ if (!$item->gotObject()) {
+ return;
+ }
+ $object = $item->getObject();
+
+ try {
+ $service = AP::$activityPub->getInterfaceForItem($object);
+ $service->delete($object);
+ } catch (UnknownItemException $e) {
+ }
+ }
+
+//
+// /**
+// * @param ACore $delete
+// *
+// * @throws InvalidOriginException
+// */
+// public function processIncomingRequest(ACore $delete) {
+//
+// if ($delete->gotObject()) {
+// $id = $delete->getObject()
+// ->getId();
+// } else {
+// $id = $delete->getObjectId();
+// }
+//
+// $delete->checkOrigin($id);
+//
+//
+// /** @var Delete $delete */
+// try {