2018-12-16 22:53:00 +00:00
|
|
|
<?php
|
2022-04-15 11:34:01 +00:00
|
|
|
|
2018-12-16 22:53:00 +00:00
|
|
|
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;
|
|
|
|
|
2022-06-17 14:29:54 +00:00
|
|
|
use OCA\Social\Tools\Traits\TArrayTools;
|
2019-01-03 11:36:46 +00:00
|
|
|
use OCA\Social\Exceptions\ItemUnknownException;
|
2018-12-16 22:53:00 +00:00
|
|
|
use OCA\Social\Exceptions\RedundancyLimitException;
|
|
|
|
use OCA\Social\Exceptions\SocialAppConfigException;
|
|
|
|
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\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;
|
2020-08-01 01:12:01 +00:00
|
|
|
use OCA\Social\Interfaces\Actor\ServiceInterface;
|
2020-11-23 06:50:16 +00:00
|
|
|
use OCA\Social\Interfaces\Actor\GroupInterface;
|
|
|
|
use OCA\Social\Interfaces\Actor\OrganizationInterface;
|
|
|
|
use OCA\Social\Interfaces\Actor\ApplicationInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
use OCA\Social\Interfaces\IActivityPubInterface;
|
2018-12-29 13:49:31 +00:00
|
|
|
use OCA\Social\Interfaces\Internal\SocialAppNotificationInterface;
|
2020-08-01 01:12:01 +00:00
|
|
|
use OCA\Social\Interfaces\Object\AnnounceInterface;
|
2019-01-18 16:51:43 +00:00
|
|
|
use OCA\Social\Interfaces\Object\DocumentInterface;
|
2020-08-01 01:12:01 +00:00
|
|
|
use OCA\Social\Interfaces\Object\FollowInterface;
|
2019-01-18 16:51:43 +00:00
|
|
|
use OCA\Social\Interfaces\Object\ImageInterface;
|
2020-08-01 01:12:01 +00:00
|
|
|
use OCA\Social\Interfaces\Object\LikeInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
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\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;
|
2020-08-01 01:12:01 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Actor\Service;
|
2020-11-23 06:50:16 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Actor\Group;
|
|
|
|
use OCA\Social\Model\ActivityPub\Actor\Organization;
|
|
|
|
use OCA\Social\Model\ActivityPub\Actor\Application;
|
2020-08-01 01:12:01 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Internal\SocialAppNotification;
|
2019-01-21 16:10:41 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Object\Announce;
|
2018-12-16 22:53:00 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Object\Document;
|
2020-08-01 01:12:01 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Object\Follow;
|
2018-12-16 22:53:00 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Object\Image;
|
2020-08-01 01:12:01 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Object\Like;
|
2018-12-16 22:53:00 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Object\Note;
|
|
|
|
use OCA\Social\Model\ActivityPub\Object\Tombstone;
|
2019-05-29 17:47:09 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Stream;
|
2018-12-16 22:53:00 +00:00
|
|
|
use OCA\Social\Service\ConfigService;
|
|
|
|
use OCP\AppFramework\QueryException;
|
2022-05-11 16:22:54 +00:00
|
|
|
use OCP\Server;
|
|
|
|
use Psr\Log\LoggerInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class AP
|
|
|
|
*
|
|
|
|
* @package OCA\Social
|
|
|
|
*/
|
|
|
|
class AP {
|
|
|
|
use TArrayTools;
|
|
|
|
|
2022-04-15 11:34:01 +00:00
|
|
|
public const REDUNDANCY_LIMIT = 10;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
2022-05-11 16:22:54 +00:00
|
|
|
public AcceptInterface $acceptInterface;
|
|
|
|
public AddInterface $addInterface;
|
|
|
|
public AnnounceInterface $announceInterface;
|
|
|
|
public BlockInterface $blockInterface;
|
|
|
|
public CreateInterface $createInterface;
|
|
|
|
public DeleteInterface $deleteInterface;
|
|
|
|
public DocumentInterface $documentInterface;
|
|
|
|
public FollowInterface $followInterface;
|
|
|
|
public ImageInterface $imageInterface;
|
|
|
|
public LikeInterface $likeInterface;
|
|
|
|
public PersonInterface $personInterface;
|
|
|
|
public NoteInterface $noteInterface;
|
|
|
|
public GroupInterface $groupInterface;
|
|
|
|
public OrganizationInterface $organizationInterface;
|
|
|
|
public ApplicationInterface $applicationInterface;
|
|
|
|
public RejectInterface $rejectInterface;
|
|
|
|
public RemoveInterface $removeInterface;
|
|
|
|
public ServiceInterface $serviceInterface;
|
|
|
|
public UndoInterface $undoInterface;
|
|
|
|
public UpdateInterface $updateInterface;
|
|
|
|
public SocialAppNotificationInterface $notificationInterface;
|
|
|
|
public ConfigService $configService;
|
|
|
|
public static ?AP $activityPub = null;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
AcceptInterface $acceptInterface,
|
|
|
|
AddInterface $addInterface,
|
|
|
|
AnnounceInterface $announceInterface,
|
|
|
|
BlockInterface $blockInterface,
|
|
|
|
CreateInterface $createInterface,
|
|
|
|
DeleteInterface $deleteInterface,
|
|
|
|
DocumentInterface $documentInterface,
|
|
|
|
FollowInterface $followInterface,
|
|
|
|
ImageInterface $imageInterface,
|
|
|
|
LikeInterface $likeInterface,
|
|
|
|
NoteInterface $noteInterface,
|
2022-07-12 12:07:49 +00:00
|
|
|
SocialAppNotificationInterface $notificationInterface,
|
2022-05-11 16:22:54 +00:00
|
|
|
PersonInterface $personInterface,
|
|
|
|
ServiceInterface $serviceInterface,
|
|
|
|
GroupInterface $groupInterface,
|
|
|
|
OrganizationInterface $organizationInterface,
|
|
|
|
ApplicationInterface $applicationInterface,
|
|
|
|
RejectInterface $rejectInterface,
|
|
|
|
RemoveInterface $removeInterface,
|
|
|
|
UndoInterface $undoInterface,
|
|
|
|
UpdateInterface $updateInterface,
|
|
|
|
ConfigService $configService
|
|
|
|
) {
|
|
|
|
$this->acceptInterface = $acceptInterface;
|
|
|
|
$this->addInterface = $addInterface;
|
|
|
|
$this->announceInterface = $announceInterface;
|
|
|
|
$this->blockInterface = $blockInterface;
|
|
|
|
$this->createInterface = $createInterface;
|
|
|
|
$this->deleteInterface = $deleteInterface;
|
|
|
|
$this->documentInterface = $documentInterface;
|
|
|
|
$this->followInterface = $followInterface;
|
|
|
|
$this->imageInterface = $imageInterface;
|
|
|
|
$this->likeInterface = $likeInterface;
|
|
|
|
$this->noteInterface = $noteInterface;
|
2022-07-12 12:07:49 +00:00
|
|
|
$this->notificationInterface = $notificationInterface;
|
2022-05-11 16:22:54 +00:00
|
|
|
$this->personInterface = $personInterface;
|
|
|
|
$this->serviceInterface = $serviceInterface;
|
|
|
|
$this->groupInterface = $groupInterface;
|
|
|
|
$this->organizationInterface = $organizationInterface;
|
|
|
|
$this->applicationInterface = $applicationInterface;
|
|
|
|
$this->rejectInterface = $rejectInterface;
|
|
|
|
$this->removeInterface = $removeInterface;
|
|
|
|
$this->undoInterface = $undoInterface;
|
|
|
|
$this->updateInterface = $updateInterface;
|
|
|
|
$this->configService = $configService;
|
2018-12-16 22:53:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function init() {
|
|
|
|
try {
|
2022-05-11 16:22:54 +00:00
|
|
|
AP::$activityPub = Server::get(AP::class);
|
2018-12-16 22:53:00 +00:00
|
|
|
} catch (QueryException $e) {
|
2022-05-11 16:22:54 +00:00
|
|
|
Server::get(LoggerInterface::class)
|
2022-06-17 14:29:54 +00:00
|
|
|
->error($e->getMessage(), ['exception' => $e]);
|
2018-12-16 22:53:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws RedundancyLimitException
|
|
|
|
* @throws SocialAppConfigException
|
2018-12-29 14:07:57 +00:00
|
|
|
* @throws ItemUnknownException
|
2018-12-16 22:53:00 +00:00
|
|
|
*/
|
2020-08-01 01:12:01 +00:00
|
|
|
public function getItemFromData(array $data, ACore $parent = null, int $level = 0): ACore {
|
2018-12-16 22:53:00 +00:00
|
|
|
if (++$level > self::REDUNDANCY_LIMIT) {
|
|
|
|
throw new RedundancyLimitException($level);
|
|
|
|
}
|
|
|
|
|
|
|
|
$item = $this->getSimpleItemFromData($data);
|
|
|
|
if ($parent !== null) {
|
|
|
|
$item->setParent($parent);
|
|
|
|
}
|
|
|
|
|
2019-01-21 16:10:41 +00:00
|
|
|
$this->getObjectFromData($data, $item, $level);
|
2019-06-26 00:32:46 +00:00
|
|
|
$this->getActorFromData($data, $item, $level);
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-21 16:10:41 +00:00
|
|
|
/**
|
|
|
|
* @throws RedundancyLimitException
|
|
|
|
* @throws SocialAppConfigException
|
|
|
|
*/
|
|
|
|
public function getObjectFromData(array $data, ACore &$item, int $level) {
|
2018-12-16 22:53:00 +00:00
|
|
|
try {
|
2019-01-21 16:10:41 +00:00
|
|
|
$objectData = $this->getArray('object', $data, []);
|
|
|
|
if (empty($objectData)) {
|
|
|
|
$objectId = $this->get('object', $data, '');
|
|
|
|
if ($objectId !== '') {
|
|
|
|
// TODO: validate AS_URL
|
|
|
|
$item->setObjectId($objectId);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$object = $this->getItemFromData($objectData, $item, $level);
|
|
|
|
$item->setObject($object);
|
|
|
|
}
|
2018-12-29 14:07:57 +00:00
|
|
|
} catch (ItemUnknownException $e) {
|
2019-06-26 00:32:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws RedundancyLimitException
|
|
|
|
* @throws SocialAppConfigException
|
|
|
|
*/
|
|
|
|
public function getActorFromData(array $data, ACore &$item, int $level) {
|
|
|
|
try {
|
|
|
|
$actorData = $this->getArray('actor_info', $data, []);
|
|
|
|
if (!empty($actorData)) {
|
|
|
|
/** @var Person $actor */
|
|
|
|
$actor = $this->getItemFromData($actorData, $item, $level);
|
|
|
|
$item->setActor($actor);
|
|
|
|
}
|
|
|
|
} catch (ItemUnknownException $e) {
|
2018-12-16 22:53:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws SocialAppConfigException
|
2018-12-29 14:07:57 +00:00
|
|
|
* @throws ItemUnknownException
|
2018-12-16 22:53:00 +00:00
|
|
|
*/
|
|
|
|
public function getSimpleItemFromData(array $data): Acore {
|
|
|
|
$item = $this->getItemFromType($this->get('type', $data, ''));
|
|
|
|
$item->import($data);
|
|
|
|
$item->setSource(json_encode($data, JSON_UNESCAPED_SLASHES));
|
|
|
|
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $type
|
|
|
|
*
|
|
|
|
* @return ACore
|
2018-12-29 14:07:57 +00:00
|
|
|
* @throws ItemUnknownException
|
2019-01-03 11:36:46 +00:00
|
|
|
* @throws SocialAppConfigException
|
2018-12-16 22:53:00 +00:00
|
|
|
*/
|
2019-01-03 11:36:46 +00:00
|
|
|
public function getItemFromType(string $type): ACore {
|
2018-12-16 22:53:00 +00:00
|
|
|
switch ($type) {
|
|
|
|
case Accept::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Accept();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Add::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Add();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
2019-01-21 16:10:41 +00:00
|
|
|
case Announce::TYPE:
|
|
|
|
$item = new Announce();
|
2020-06-12 12:35:33 +00:00
|
|
|
$item->setFilterDuplicate(true);
|
2019-01-21 16:10:41 +00:00
|
|
|
break;
|
|
|
|
|
2018-12-16 22:53:00 +00:00
|
|
|
case Block::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Block();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Create::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Create();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Delete::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Delete();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
2019-01-18 16:51:43 +00:00
|
|
|
case Document::TYPE:
|
|
|
|
$item = new Document();
|
|
|
|
break;
|
|
|
|
|
2018-12-16 22:53:00 +00:00
|
|
|
case Follow::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Follow();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Image::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Image();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Like::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Like();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Note::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Note();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
2018-12-29 13:49:31 +00:00
|
|
|
case SocialAppNotification::TYPE:
|
2019-05-17 17:33:21 +00:00
|
|
|
$item = new SocialAppNotification();
|
|
|
|
break;
|
2018-12-29 13:49:31 +00:00
|
|
|
|
2019-05-29 17:47:09 +00:00
|
|
|
case Stream::TYPE:
|
|
|
|
$item = new Stream();
|
|
|
|
break;
|
|
|
|
|
2018-12-16 22:53:00 +00:00
|
|
|
case Person::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Person();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Reject::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Reject();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Remove::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Remove();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
2019-06-25 00:04:05 +00:00
|
|
|
case Service::TYPE:
|
|
|
|
$item = new Service();
|
|
|
|
break;
|
|
|
|
|
2020-11-23 06:50:16 +00:00
|
|
|
case Group::TYPE:
|
|
|
|
$item = new Group();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Organization::TYPE:
|
|
|
|
$item = new Organization();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Application::TYPE:
|
|
|
|
$item = new Application();
|
|
|
|
break;
|
|
|
|
|
2018-12-16 22:53:00 +00:00
|
|
|
case Tombstone::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Tombstone();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Undo::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Undo();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Update::TYPE:
|
2019-01-03 11:36:46 +00:00
|
|
|
$item = new Update();
|
|
|
|
break;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
default:
|
2018-12-29 14:07:57 +00:00
|
|
|
throw new ItemUnknownException();
|
2018-12-16 22:53:00 +00:00
|
|
|
}
|
2019-01-03 11:36:46 +00:00
|
|
|
|
2019-07-11 13:58:58 +00:00
|
|
|
$item->setUrlCloud($this->configService->getCloudUrl());
|
2019-01-03 11:36:46 +00:00
|
|
|
|
|
|
|
return $item;
|
2018-12-16 22:53:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param ACore $activity
|
|
|
|
*
|
|
|
|
* @return IActivityPubInterface
|
2018-12-29 14:07:57 +00:00
|
|
|
* @throws ItemUnknownException
|
2018-12-16 22:53:00 +00:00
|
|
|
*/
|
|
|
|
public function getInterfaceForItem(Acore $activity): IActivityPubInterface {
|
|
|
|
return $this->getInterfaceFromType($activity->getType());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $type
|
|
|
|
*
|
|
|
|
* @return IActivityPubInterface
|
2018-12-29 14:07:57 +00:00
|
|
|
* @throws ItemUnknownException
|
2018-12-16 22:53:00 +00:00
|
|
|
*/
|
|
|
|
public function getInterfaceFromType(string $type): IActivityPubInterface {
|
|
|
|
switch ($type) {
|
|
|
|
case Accept::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->acceptInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Add::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->addInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
2019-01-21 16:10:41 +00:00
|
|
|
case Announce::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->announceInterface;
|
2019-01-21 16:10:41 +00:00
|
|
|
|
2018-12-16 22:53:00 +00:00
|
|
|
case Block::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->blockInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Create::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->createInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Delete::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->deleteInterface;
|
2019-01-18 16:51:43 +00:00
|
|
|
|
|
|
|
case Document::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->documentInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Follow::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->followInterface;
|
2019-01-18 16:51:43 +00:00
|
|
|
|
|
|
|
case Image::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->imageInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Like::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->likeInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Note::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->noteInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
2018-12-29 13:49:31 +00:00
|
|
|
case SocialAppNotification::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->notificationInterface;
|
2018-12-29 13:49:31 +00:00
|
|
|
|
2018-12-16 22:53:00 +00:00
|
|
|
case Person::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->personInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Reject::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->rejectInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Remove::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->removeInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
2019-06-25 00:04:05 +00:00
|
|
|
case Service::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->serviceInterface;
|
2019-06-25 00:04:05 +00:00
|
|
|
|
2018-12-16 22:53:00 +00:00
|
|
|
case Undo::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->undoInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
case Update::TYPE:
|
2022-05-11 16:22:54 +00:00
|
|
|
return $this->updateInterface;
|
2018-12-16 22:53:00 +00:00
|
|
|
|
|
|
|
default:
|
2018-12-29 14:07:57 +00:00
|
|
|
throw new ItemUnknownException();
|
2018-12-16 22:53:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-25 00:04:05 +00:00
|
|
|
public function isActor(ACore $item): bool {
|
2022-05-11 16:22:54 +00:00
|
|
|
$types = [
|
|
|
|
Person::TYPE,
|
|
|
|
Service::TYPE,
|
|
|
|
Group::TYPE,
|
|
|
|
Organization::TYPE,
|
|
|
|
Application::TYPE
|
|
|
|
];
|
2019-06-25 00:04:05 +00:00
|
|
|
|
|
|
|
return (in_array($item->getType(), $types));
|
|
|
|
}
|
2018-12-16 22:53:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AP::init();
|