kopia lustrzana https://github.com/nextcloud/social
moving stuff around
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/226/head
rodzic
a72039c212
commit
7f2eede76b
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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, ''));
|
||||
|
|
|
@ -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(),
|
||||
[
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 Block
|
||||
*
|
||||
* @package OCA\Social\Model\ActivityPub\Activity
|
||||
*/
|
||||
class Block extends ACore implements JsonSerializable {
|
||||
|
||||
|
||||
const TYPE = 'Block';
|
||||
|
||||
|
||||
/**
|
||||
* Block 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(),
|
||||
[
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ class Create extends ACore implements JsonSerializable {
|
|||
|
||||
|
||||
/**
|
||||
* Activity constructor.
|
||||
* Create constructor.
|
||||
*
|
||||
* @param ACore $parent
|
||||
*/
|
||||
|
@ -63,7 +63,6 @@ class Create extends ACore implements JsonSerializable {
|
|||
*/
|
||||
public function import(array $data) {
|
||||
parent::import($data);
|
||||
$this->setActorId($this->validate(ACore::AS_ID, 'actor', $data, ''));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Social\Model\ActivityPub;
|
||||
namespace OCA\Social\Model\ActivityPub\Activity;
|
||||
|
||||
|
||||
use JsonSerializable;
|
||||
use OCA\Social\Exceptions\InvalidResourceEntryException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -105,8 +105,6 @@ class Follow extends ACore implements JsonSerializable {
|
|||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @throws InvalidResourceEntryException
|
||||
*/
|
||||
public function import(array $data) {
|
||||
parent::import($data);
|
|
@ -28,51 +28,53 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Social\Service\ActivityPub;
|
||||
namespace OCA\Social\Model\ActivityPub\Activity;
|
||||
|
||||
|
||||
use Exception;
|
||||
use JsonSerializable;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Service\MiscService;
|
||||
|
||||
|
||||
class UndoService implements ICoreService {
|
||||
/**
|
||||
* Class Like
|
||||
*
|
||||
* @package OCA\Social\Model\ActivityPub\Activity
|
||||
*/
|
||||
class Like extends ACore implements JsonSerializable {
|
||||
|
||||
|
||||
/** @var MiscService */
|
||||
private $miscService;
|
||||
const TYPE = 'Like';
|
||||
|
||||
|
||||
/**
|
||||
* UndoService constructor.
|
||||
* Like constructor.
|
||||
*
|
||||
* @param MiscService $miscService
|
||||
* @param ACore $parent
|
||||
*/
|
||||
public function __construct(MiscService $miscService) {
|
||||
$this->miscService = $miscService;
|
||||
public function __construct($parent = null) {
|
||||
parent::__construct($parent);
|
||||
|
||||
$this->setType(self::TYPE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $undo
|
||||
*
|
||||
* @throws Exception
|
||||
* @param array $data
|
||||
*/
|
||||
public function parse(ACore $undo) {
|
||||
public function import(array $data) {
|
||||
parent::import($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @return array
|
||||
*/
|
||||
public function save(ACore $item) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
*/
|
||||
public function delete(ACore $item) {
|
||||
public function jsonSerialize(): array {
|
||||
return array_merge(
|
||||
parent::jsonSerialize(),
|
||||
[
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -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 Remove
|
||||
*
|
||||
* @package OCA\Social\Model\ActivityPub\Activity
|
||||
*/
|
||||
class Remove extends ACore implements JsonSerializable {
|
||||
|
||||
|
||||
const TYPE = 'Remove';
|
||||
|
||||
|
||||
/**
|
||||
* Remove 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(),
|
||||
[
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 Update
|
||||
*
|
||||
* @package OCA\Social\Model\ActivityPub\Activity
|
||||
*/
|
||||
class Update extends ACore implements JsonSerializable {
|
||||
|
||||
|
||||
const TYPE = 'Update';
|
||||
|
||||
|
||||
/**
|
||||
* Update 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(),
|
||||
[
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -28,12 +28,14 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Social\Model\ActivityPub;
|
||||
namespace OCA\Social\Model\ActivityPub\Actor;
|
||||
|
||||
|
||||
use JsonSerializable;
|
||||
use OCA\Social\Exceptions\InvalidResourceEntryException;
|
||||
use OCA\Social\Exceptions\UrlCloudException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\ActivityPub\Object\Image;
|
||||
|
||||
|
||||
/**
|
|
@ -30,6 +30,7 @@ declare(strict_types=1);
|
|||
namespace OCA\Social\Model\ActivityPub;
|
||||
|
||||
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
use OCA\Social\Model\InstancePath;
|
||||
|
||||
|
||||
|
|
|
@ -28,13 +28,14 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Social\Model\ActivityPub;
|
||||
namespace OCA\Social\Model\ActivityPub\Object;
|
||||
|
||||
|
||||
use DateTime;
|
||||
use JsonSerializable;
|
||||
use OCA\Social\Exceptions\InvalidResourceEntryException;
|
||||
use OCA\Social\Exceptions\UrlCloudException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
|
||||
|
||||
/**
|
|
@ -28,11 +28,12 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Social\Model\ActivityPub;
|
||||
namespace OCA\Social\Model\ActivityPub\Object;
|
||||
|
||||
|
||||
use JsonSerializable;
|
||||
use OCA\Social\Exceptions\UrlCloudException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
|
||||
|
||||
/**
|
|
@ -27,11 +27,12 @@ declare(strict_types=1);
|
|||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Social\Model\ActivityPub;
|
||||
namespace OCA\Social\Model\ActivityPub\Object;
|
||||
|
||||
|
||||
use DateTime;
|
||||
use JsonSerializable;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Service\ActivityService;
|
||||
|
||||
class Note extends ACore implements JsonSerializable {
|
|
@ -28,10 +28,11 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Social\Model\ActivityPub;
|
||||
namespace OCA\Social\Model\ActivityPub\Object;
|
||||
|
||||
|
||||
use JsonSerializable;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
|
||||
|
||||
/**
|
|
@ -0,0 +1,105 @@
|
|||
<?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\Service\ActivityPub\Activity;
|
||||
|
||||
|
||||
use OCA\Social\Exceptions\UnknownItemException;
|
||||
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 {
|
||||
|
||||
|
||||
/** @var MiscService */
|
||||
private $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* AcceptService constructor.
|
||||
*
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(MiscService $miscService) {
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processIncomingRequest(ACore $item, ImportService $importService) {
|
||||
if (!$item->gotObject()) {
|
||||
return;
|
||||
}
|
||||
$object = $item->getObject();
|
||||
|
||||
try {
|
||||
$service = $importService->getServiceForItem($item->getObject());
|
||||
$service->activity($item, $object);
|
||||
} catch (UnknownItemException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
<?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\Service\ActivityPub\Activity;
|
||||
|
||||
|
||||
use OCA\Social\Exceptions\UnknownItemException;
|
||||
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 {
|
||||
|
||||
|
||||
/** @var MiscService */
|
||||
private $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* AddService constructor.
|
||||
*
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(MiscService $miscService) {
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processIncomingRequest(ACore $item, ImportService $importService) {
|
||||
if (!$item->gotObject()) {
|
||||
return;
|
||||
}
|
||||
$object = $item->getObject();
|
||||
|
||||
try {
|
||||
$service = $importService->getServiceForItem($item->getObject());
|
||||
$service->activity($item, $object);
|
||||
} catch (UnknownItemException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
<?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\Service\ActivityPub\Activity;
|
||||
|
||||
|
||||
use OCA\Social\Exceptions\UnknownItemException;
|
||||
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 {
|
||||
|
||||
|
||||
/** @var MiscService */
|
||||
private $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* BlockService constructor.
|
||||
*
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(MiscService $miscService) {
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processIncomingRequest(ACore $item, ImportService $importService) {
|
||||
if (!$item->gotObject()) {
|
||||
return;
|
||||
}
|
||||
$object = $item->getObject();
|
||||
|
||||
try {
|
||||
$service = $importService->getServiceForItem($item->getObject());
|
||||
$service->activity($item, $object);
|
||||
} catch (UnknownItemException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<?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\Service\ActivityPub\Activity;
|
||||
|
||||
|
||||
use OCA\Social\Exceptions\UnknownItemException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
|
||||
|
||||
class CreateService implements ICoreService {
|
||||
|
||||
|
||||
/** @var MiscService */
|
||||
private $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* CreateService constructor.
|
||||
*
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(MiscService $miscService) {
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processIncomingRequest(ACore $item, ImportService $importService) {
|
||||
if (!$item->gotObject()) {
|
||||
return;
|
||||
}
|
||||
$object = $item->getObject();
|
||||
|
||||
try {
|
||||
$service = $importService->getServiceForItem($item->getObject());
|
||||
$service->activity($item, $object);
|
||||
} catch (UnknownItemException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
}
|
||||
}
|
||||
|
|
@ -28,31 +28,26 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Social\Service\ActivityPub;
|
||||
namespace OCA\Social\Service\ActivityPub\Activity;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OCA\Social\Db\NotesRequest;
|
||||
use OCA\Social\Exceptions\InvalidOriginException;
|
||||
use OCA\Social\Exceptions\InvalidResourceException;
|
||||
use OCA\Social\Exceptions\UnknownItemException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Delete;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\ActivityService;
|
||||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
|
||||
|
||||
class DeleteService implements ICoreService {
|
||||
|
||||
|
||||
/** @var NotesRequest */
|
||||
private $notesRequest;
|
||||
|
||||
/** @var ActivityService */
|
||||
private $activityService;
|
||||
|
||||
/** @var NoteService */
|
||||
private $noteService;
|
||||
|
||||
/** @var MiscService */
|
||||
private $miscService;
|
||||
|
@ -61,33 +56,22 @@ class DeleteService implements ICoreService {
|
|||
/**
|
||||
* UndoService constructor.
|
||||
*
|
||||
* @param NotesRequest $notesRequest
|
||||
* @param ActivityService $activityService
|
||||
* @param NoteService $noteService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
NotesRequest $notesRequest, ActivityService $activityService, NoteService $noteService,
|
||||
MiscService $miscService
|
||||
) {
|
||||
$this->notesRequest = $notesRequest;
|
||||
public function __construct(ActivityService $activityService, MiscService $miscService) {
|
||||
$this->activityService = $activityService;
|
||||
$this->noteService = $noteService;
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $delete
|
||||
* @param ImportService $importService
|
||||
*
|
||||
* @throws UnknownItemException
|
||||
* @throws InvalidOriginException
|
||||
*/
|
||||
public function parse(ACore $delete) {
|
||||
|
||||
if (!$delete->isRoot()) {
|
||||
throw new UnknownItemException();
|
||||
}
|
||||
public function processIncomingRequest(ACore $delete, ImportService $importService) {
|
||||
|
||||
if ($delete->gotObject()) {
|
||||
$id = $delete->getObject()
|
||||
|
@ -101,29 +85,35 @@ class DeleteService implements ICoreService {
|
|||
/** @var Delete $delete */
|
||||
try {
|
||||
$item = $this->activityService->getItem($id);
|
||||
$service = $importService->getServiceForItem($item);
|
||||
|
||||
switch ($item->getType()) {
|
||||
|
||||
case 'Note':
|
||||
$service = $this->noteService;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnknownItemException();
|
||||
}
|
||||
|
||||
try {
|
||||
$service->delete($item);
|
||||
} catch (Exception $e) {
|
||||
$this->miscService->log(
|
||||
2, 'Cannot delete ' . $delete->getType() . ': ' . $e->getMessage()
|
||||
);
|
||||
}
|
||||
// we could use ->activity($delete, $item) but the delete() is important enough to
|
||||
// be here, and to use it.
|
||||
$service->delete($item);
|
||||
} catch (UnknownItemException $e) {
|
||||
} catch (InvalidResourceException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $activity
|
||||
* @param ACore $item
|
||||
*/
|
||||
public function activity(Acore $activity, ACore $item) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
*/
|
|
@ -28,29 +28,35 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Social\Service\ActivityPub;
|
||||
namespace OCA\Social\Service\ActivityPub\Activity;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
|
||||
use Exception;
|
||||
use OCA\Social\Db\FollowsRequest;
|
||||
use OCA\Social\Exceptions\ActorDoesNotExistException;
|
||||
use OCA\Social\Exceptions\CacheActorDoesNotExistException;
|
||||
use OCA\Social\Exceptions\FollowDoesNotExistException;
|
||||
use OCA\Social\Exceptions\FollowSameAccountException;
|
||||
use OCA\Social\Exceptions\InvalidOriginException;
|
||||
use OCA\Social\Exceptions\InvalidResourceException;
|
||||
use OCA\Social\Exceptions\Request410Exception;
|
||||
use OCA\Social\Exceptions\RequestException;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Exceptions\UrlCloudException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Accept;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Follow;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Reject;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Undo;
|
||||
use OCA\Social\Model\ActivityPub\Follow;
|
||||
use OCA\Social\Model\ActivityPub\OrderedCollection;
|
||||
use OCA\Social\Model\ActivityPub\Person;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
use OCA\Social\Model\InstancePath;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\ActivityPub\Actor\PersonService;
|
||||
use OCA\Social\Service\ActivityService;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
|
||||
|
||||
|
@ -225,6 +231,14 @@ class FollowService implements ICoreService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Follow $follow
|
||||
*/
|
||||
|
@ -257,54 +271,62 @@ class FollowService implements ICoreService {
|
|||
* This method is called when saving the Follow object
|
||||
*
|
||||
* @param ACore $follow
|
||||
* @param ImportService $importService
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws InvalidResourceException
|
||||
* @throws RequestException
|
||||
* @throws SocialAppConfigException
|
||||
* @throws UrlCloudException
|
||||
* @throws InvalidOriginException
|
||||
* @throws Request410Exception
|
||||
* @throws MalformedArrayException
|
||||
*/
|
||||
public function parse(ACore $follow) {
|
||||
|
||||
public function processIncomingRequest(ACore $follow, ImportService $importService) {
|
||||
/** @var Follow $follow */
|
||||
if ($follow->isRoot()) {
|
||||
$follow->checkOrigin($follow->getActorId());
|
||||
$follow->checkOrigin($follow->getActorId());
|
||||
|
||||
try {
|
||||
$knownFollow = $this->followsRequest->getByPersons(
|
||||
$follow->getActorId(), $follow->getObjectId()
|
||||
);
|
||||
// in case of local follower.
|
||||
// TODO - remove when following a local account does not need curl request anymore
|
||||
if ($knownFollow->getId() === $follow->getId() && !$knownFollow->isAccepted()) {
|
||||
$this->confirmFollowRequest($follow);
|
||||
}
|
||||
} catch (FollowDoesNotExistException $e) {
|
||||
$actor = $this->personService->getFromId($follow->getObjectId());
|
||||
if ($actor->isLocal()) {
|
||||
$follow->setFollowId($actor->getFollowers());
|
||||
$this->followsRequest->save($follow);
|
||||
$this->confirmFollowRequest($follow);
|
||||
}
|
||||
try {
|
||||
$knownFollow = $this->followsRequest->getByPersons(
|
||||
$follow->getActorId(), $follow->getObjectId()
|
||||
);
|
||||
|
||||
if ($knownFollow->getId() === $follow->getId() && !$knownFollow->isAccepted()) {
|
||||
$this->confirmFollowRequest($follow);
|
||||
}
|
||||
|
||||
} else {
|
||||
$parent = $follow->getParent();
|
||||
if (!$parent->isRoot()) {
|
||||
return;
|
||||
} catch (FollowDoesNotExistException $e) {
|
||||
$actor = $this->personService->getFromId($follow->getObjectId());
|
||||
if ($actor->isLocal()) {
|
||||
$follow->setFollowId($actor->getFollowers());
|
||||
$this->followsRequest->save($follow);
|
||||
$this->confirmFollowRequest($follow);
|
||||
}
|
||||
}
|
||||
|
||||
if ($parent->getType() === Undo::TYPE) {
|
||||
$parent->checkOrigin($follow->getActorId());
|
||||
$this->followsRequest->deleteByPersons($follow);
|
||||
}
|
||||
// } else {
|
||||
}
|
||||
|
||||
if ($parent->getType() === Reject::TYPE) {
|
||||
$parent->checkOrigin($follow->getObjectId());
|
||||
$this->followsRequest->deleteByPersons($follow);
|
||||
}
|
||||
|
||||
if ($parent->getType() === Accept::TYPE) {
|
||||
$parent->checkOrigin($follow->getObjectId());
|
||||
$this->followsRequest->accepted($follow);
|
||||
}
|
||||
/**
|
||||
* @param ACore $activity
|
||||
* @param ACore $item
|
||||
*
|
||||
* @throws InvalidOriginException
|
||||
*/
|
||||
public function activity(Acore $activity, ACore $item) {
|
||||
/** @var Follow $item */
|
||||
if ($activity->getType() === Undo::TYPE) {
|
||||
$activity->checkOrigin($item->getActorId());
|
||||
$this->followsRequest->deleteByPersons($item);
|
||||
}
|
||||
|
||||
if ($activity->getType() === Reject::TYPE) {
|
||||
$activity->checkOrigin($item->getObjectId());
|
||||
$this->followsRequest->deleteByPersons($item);
|
||||
}
|
||||
|
||||
if ($activity->getType() === Accept::TYPE) {
|
||||
$activity->checkOrigin($item->getObjectId());
|
||||
$this->followsRequest->accepted($item);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<?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\Service\ActivityPub\Activity;
|
||||
|
||||
|
||||
use OCA\Social\Exceptions\UnknownItemException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
|
||||
|
||||
class LikeService implements ICoreService {
|
||||
|
||||
|
||||
/** @var MiscService */
|
||||
private $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* LikeService constructor.
|
||||
*
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(MiscService $miscService) {
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processIncomingRequest(ACore $item, ImportService $importService) {
|
||||
if (!$item->gotObject()) {
|
||||
return;
|
||||
}
|
||||
$object = $item->getObject();
|
||||
|
||||
try {
|
||||
$service = $importService->getServiceForItem($item->getObject());
|
||||
$service->activity($item, $object);
|
||||
} catch (UnknownItemException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
<?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\Service\ActivityPub\Activity;
|
||||
|
||||
|
||||
use OCA\Social\Exceptions\UnknownItemException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
|
||||
|
||||
class RejectService implements ICoreService {
|
||||
|
||||
|
||||
/** @var MiscService */
|
||||
private $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* RejectService constructor.
|
||||
*
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(MiscService $miscService) {
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processIncomingRequest(ACore $item, ImportService $importService) {
|
||||
if (!$item->gotObject()) {
|
||||
return;
|
||||
}
|
||||
$object = $item->getObject();
|
||||
|
||||
try {
|
||||
$service = $importService->getServiceForItem($item->getObject());
|
||||
$service->activity($item, $object);
|
||||
} catch (UnknownItemException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
<?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\Service\ActivityPub\Activity;
|
||||
|
||||
|
||||
use OCA\Social\Exceptions\UnknownItemException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
|
||||
|
||||
class RemoveService implements ICoreService {
|
||||
|
||||
|
||||
/** @var MiscService */
|
||||
private $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* RemoveService constructor.
|
||||
*
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(MiscService $miscService) {
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processIncomingRequest(ACore $item, ImportService $importService) {
|
||||
if (!$item->gotObject()) {
|
||||
return;
|
||||
}
|
||||
$object = $item->getObject();
|
||||
|
||||
try {
|
||||
$service = $importService->getServiceForItem($item->getObject());
|
||||
$service->activity($item, $object);
|
||||
} catch (UnknownItemException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<?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\Service\ActivityPub\Activity;
|
||||
|
||||
|
||||
use OCA\Social\Exceptions\UnknownItemException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
|
||||
|
||||
class UndoService implements ICoreService {
|
||||
|
||||
|
||||
/** @var MiscService */
|
||||
private $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* UndoService constructor.
|
||||
*
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(MiscService $miscService) {
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processIncomingRequest(ACore $item, ImportService $importService) {
|
||||
if (!$item->gotObject()) {
|
||||
return;
|
||||
}
|
||||
$object = $item->getObject();
|
||||
|
||||
try {
|
||||
$service = $importService->getServiceForItem($item->getObject());
|
||||
$service->activity($item, $object);
|
||||
} catch (UnknownItemException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<?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\Service\ActivityPub\Activity;
|
||||
|
||||
|
||||
use OCA\Social\Exceptions\UnknownItemException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
|
||||
|
||||
class UpdateService implements ICoreService {
|
||||
|
||||
|
||||
/** @var MiscService */
|
||||
private $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateService constructor.
|
||||
*
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(MiscService $miscService) {
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processIncomingRequest(ACore $item, ImportService $importService) {
|
||||
if (!$item->gotObject()) {
|
||||
return;
|
||||
}
|
||||
$object = $item->getObject();
|
||||
|
||||
try {
|
||||
$service = $importService->getServiceForItem($item->getObject());
|
||||
$service->activity($item, $object);
|
||||
} catch (UnknownItemException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Social\Service\ActivityPub;
|
||||
namespace OCA\Social\Service\ActivityPub\Actor;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
|
||||
|
@ -45,8 +45,11 @@ use OCA\Social\Exceptions\RequestException;
|
|||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Exceptions\UrlCloudException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\ActivityPub\Person;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Update;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\InstanceService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
|
||||
|
@ -257,20 +260,23 @@ class PersonService implements ICoreService {
|
|||
|
||||
|
||||
/**
|
||||
* This method is called when saving the Follow object
|
||||
*
|
||||
* @param ACore $person
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function parse(ACore $person) {
|
||||
/** @var Person $person */
|
||||
if ($person->isRoot() === false || $person->getId() === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->save($person);
|
||||
public function processIncomingRequest(ACore $person, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $person
|
||||
*/
|
||||
|
@ -292,6 +298,18 @@ class PersonService implements ICoreService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $activity
|
||||
* @param ACore $item
|
||||
*/
|
||||
public function activity(Acore $activity, ACore $item) {
|
||||
/** @var Person $item */
|
||||
if ($activity->getType() === Update::TYPE) {
|
||||
$this->miscService->log('### UPDATE PERSON !' . json_encode($item));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @return int
|
|
@ -32,6 +32,7 @@ namespace OCA\Social\Service\ActivityPub;
|
|||
|
||||
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Service\ImportService;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -43,18 +44,43 @@ interface ICoreService {
|
|||
|
||||
|
||||
/**
|
||||
* Freshly imported item can be processed/parsed on incoming Request.
|
||||
*
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function parse(ACore $item);
|
||||
public function processIncomingRequest(ACore $item, ImportService $importService);
|
||||
|
||||
|
||||
/**
|
||||
* Freshly imported item can be processed/parsed on result of outgoing request.
|
||||
*
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService);
|
||||
|
||||
|
||||
/**
|
||||
* When an activity is triggered by an 'Model\ActivityPub\Activity' model.
|
||||
*
|
||||
* @param ACore $activity
|
||||
* @param ACore $item
|
||||
*/
|
||||
public function activity(ACore $activity, ACore $item);
|
||||
|
||||
|
||||
/**
|
||||
* Save the current item.
|
||||
*
|
||||
* @param ACore $item
|
||||
*/
|
||||
public function save(ACore $item);
|
||||
|
||||
|
||||
/**
|
||||
* Delete the current item.
|
||||
*
|
||||
* @param ACore $item
|
||||
*/
|
||||
public function delete(ACore $item);
|
||||
|
|
|
@ -28,7 +28,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Social\Service\ActivityPub;
|
||||
namespace OCA\Social\Service\ActivityPub\Object;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
@ -41,11 +41,13 @@ use OCA\Social\Exceptions\CacheDocumentDoesNotExistException;
|
|||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Exceptions\UrlCloudException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\ActivityPub\Document;
|
||||
use OCA\Social\Model\ActivityPub\Image;
|
||||
use OCA\Social\Model\ActivityPub\Person;
|
||||
use OCA\Social\Model\ActivityPub\Object\Document;
|
||||
use OCA\Social\Model\ActivityPub\Object\Image;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\CacheService;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
use OCP\Files\NotPermittedException;
|
||||
use OCP\Files\SimpleFS\ISimpleFile;
|
||||
|
@ -232,9 +234,26 @@ class DocumentService implements ICoreService {
|
|||
|
||||
|
||||
/**
|
||||
* @param ACore $activity
|
||||
* @param ACore $item
|
||||
*/
|
||||
public function parse(ACore $item) {
|
||||
public function activity(Acore $activity, ACore $item) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processIncomingRequest(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Social\Service\ActivityPub;
|
||||
namespace OCA\Social\Service\ActivityPub\Object;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
@ -41,13 +41,16 @@ use OCA\Social\Exceptions\RequestException;
|
|||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Create;
|
||||
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 OCA\Social\Service\ActivityPub\Actor\PersonService;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\ActivityService;
|
||||
use OCA\Social\Service\ActorService;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\CurlService;
|
||||
use OCA\Social\Service\ImportService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
|
||||
|
||||
|
@ -273,28 +276,18 @@ class NoteService implements ICoreService {
|
|||
|
||||
|
||||
/**
|
||||
* This method is called when saving the Note object
|
||||
*
|
||||
* @param ACore $note
|
||||
*
|
||||
* @throws InvalidOriginException
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function parse(ACore $note) {
|
||||
public function processIncomingRequest(ACore $note, ImportService $importService) {
|
||||
}
|
||||
|
||||
/** @var Note $note */
|
||||
if ($note->isRoot()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$parent = $note->getParent();
|
||||
if (!$parent->isRoot()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($parent->getType() === Create::TYPE) {
|
||||
$parent->checkOrigin($note->getAttributedTo());
|
||||
$this->save($note);
|
||||
}
|
||||
/**
|
||||
* @param ACore $item
|
||||
* @param ImportService $importService
|
||||
*/
|
||||
public function processResult(ACore $item, ImportService $importService) {
|
||||
}
|
||||
|
||||
|
||||
|
@ -312,6 +305,22 @@ class NoteService implements ICoreService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $activity
|
||||
* @param ACore $item
|
||||
*
|
||||
* @throws InvalidOriginException
|
||||
*/
|
||||
public function activity(Acore $activity, ACore $item) {
|
||||
/** @var Note $item */
|
||||
|
||||
if ($activity->getType() === Create::TYPE) {
|
||||
$activity->checkOrigin($item->getAttributedTo());
|
||||
$this->save($item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Note $note
|
||||
*
|
||||
|
@ -404,6 +413,7 @@ class NoteService implements ICoreService {
|
|||
*/
|
||||
public function getStreamInternalTimeline(int $since = 0, int $limit = 5): array {
|
||||
// TODO - admin should be able to provide a list of 'friendly/internal' instance of ActivityPub
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
@ -53,11 +53,11 @@ use OCA\Social\Exceptions\UrlCloudException;
|
|||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Create;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Delete;
|
||||
use OCA\Social\Model\ActivityPub\Person;
|
||||
use OCA\Social\Model\ActivityPub\Tombstone;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
use OCA\Social\Model\ActivityPub\Object\Tombstone;
|
||||
use OCA\Social\Model\InstancePath;
|
||||
use OCA\Social\Model\RequestQueue;
|
||||
use OCA\Social\Service\ActivityPub\PersonService;
|
||||
use OCA\Social\Service\ActivityPub\Actor\PersonService;
|
||||
use OCP\IRequest;
|
||||
|
||||
class ActivityService {
|
||||
|
@ -482,7 +482,7 @@ class ActivityService {
|
|||
/**
|
||||
* @param IRequest $request
|
||||
*
|
||||
* @return
|
||||
* @return string
|
||||
* @throws InvalidResourceException
|
||||
* @throws MalformedArrayException
|
||||
* @throws Request410Exception
|
||||
|
@ -492,7 +492,7 @@ class ActivityService {
|
|||
* @throws UrlCloudException
|
||||
* @throws InvalidOriginException
|
||||
*/
|
||||
private function checkSignature(IRequest $request) {
|
||||
private function checkSignature(IRequest $request): string {
|
||||
$signatureHeader = $request->getHeader('Signature');
|
||||
|
||||
$sign = $this->parseSignatureHeader($signatureHeader);
|
||||
|
|
|
@ -41,9 +41,9 @@ use OCA\Social\Exceptions\ActorDoesNotExistException;
|
|||
use OCA\Social\Exceptions\FollowDoesNotExistException;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Exceptions\UrlCloudException;
|
||||
use OCA\Social\Model\ActivityPub\Person;
|
||||
use OCA\Social\Service\ActivityPub\DocumentService;
|
||||
use OCA\Social\Service\ActivityPub\PersonService;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
use OCA\Social\Service\ActivityPub\Object\DocumentService;
|
||||
use OCA\Social\Service\ActivityPub\Actor\PersonService;
|
||||
use OCP\Accounts\IAccountManager;
|
||||
use OCP\IUserManager;
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@ namespace OCA\Social\Service;
|
|||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use daita\MySmallPhpTools\Traits\TPathTools;
|
||||
use OC\IntegrityCheck\Helpers\AppLocator;
|
||||
use OCA\Files\App;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCP\IConfig;
|
||||
|
|
|
@ -35,25 +35,40 @@ use daita\MySmallPhpTools\Traits\TArrayTools;
|
|||
use Exception;
|
||||
use OCA\Social\Exceptions\ActivityPubFormatException;
|
||||
use OCA\Social\Exceptions\InvalidResourceEntryException;
|
||||
use OCA\Social\Exceptions\InvalidResourceException;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Exceptions\UnknownItemException;
|
||||
use OCA\Social\Exceptions\UrlCloudException;
|
||||
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\Tombstone;
|
||||
use OCA\Social\Model\ActivityPub\Document;
|
||||
use OCA\Social\Model\ActivityPub\Follow;
|
||||
use OCA\Social\Model\ActivityPub\Image;
|
||||
use OCA\Social\Model\ActivityPub\Note;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Remove;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Undo;
|
||||
use OCA\Social\Service\ActivityPub\DeleteService;
|
||||
use OCA\Social\Service\ActivityPub\FollowService;
|
||||
use OCA\Social\Service\ActivityPub\NoteService;
|
||||
use OCA\Social\Service\ActivityPub\UndoService;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Update;
|
||||
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\Actor\Person;
|
||||
use OCA\Social\Model\ActivityPub\Object\Tombstone;
|
||||
use OCA\Social\Service\ActivityPub\Activity\AcceptService;
|
||||
use OCA\Social\Service\ActivityPub\Activity\AddService;
|
||||
use OCA\Social\Service\ActivityPub\Activity\BlockService;
|
||||
use OCA\Social\Service\ActivityPub\Activity\CreateService;
|
||||
use OCA\Social\Service\ActivityPub\Activity\DeleteService;
|
||||
use OCA\Social\Service\ActivityPub\Activity\FollowService;
|
||||
use OCA\Social\Service\ActivityPub\Activity\LikeService;
|
||||
use OCA\Social\Service\ActivityPub\Activity\RejectService;
|
||||
use OCA\Social\Service\ActivityPub\Activity\RemoveService;
|
||||
use OCA\Social\Service\ActivityPub\Activity\UndoService;
|
||||
use OCA\Social\Service\ActivityPub\Activity\UpdateService;
|
||||
use OCA\Social\Service\ActivityPub\ICoreService;
|
||||
use OCA\Social\Service\ActivityPub\Object\NoteService;
|
||||
use OCA\Social\Service\ActivityPub\Actor\PersonService;
|
||||
|
||||
|
||||
class ImportService {
|
||||
|
@ -61,18 +76,44 @@ class ImportService {
|
|||
|
||||
use TArrayTools;
|
||||
|
||||
/** @var AcceptService */
|
||||
private $acceptService;
|
||||
|
||||
/** @var NoteService */
|
||||
private $noteService;
|
||||
/** @var AddService */
|
||||
private $addService;
|
||||
|
||||
/** @var UndoService */
|
||||
private $undoService;
|
||||
/** @var BlockService */
|
||||
private $blockService;
|
||||
|
||||
/** @var CreateService */
|
||||
private $createService;
|
||||
|
||||
/** @var DeleteService */
|
||||
private $deleteService;
|
||||
|
||||
/** @var FollowService */
|
||||
private $followService;
|
||||
|
||||
/** @var DeleteService */
|
||||
private $deleteService;
|
||||
/** @var LikeService */
|
||||
private $likeService;
|
||||
|
||||
/** @var PersonService */
|
||||
private $personService;
|
||||
|
||||
/** @var NoteService */
|
||||
private $noteService;
|
||||
|
||||
/** @var RejectService */
|
||||
private $rejectService;
|
||||
|
||||
/** @var RemoveService */
|
||||
private $removeService;
|
||||
|
||||
/** @var UndoService */
|
||||
private $undoService;
|
||||
|
||||
/** @var UpdateService */
|
||||
private $updateService;
|
||||
|
||||
/** @var ConfigService */
|
||||
private $configService;
|
||||
|
@ -84,21 +125,43 @@ class ImportService {
|
|||
/**
|
||||
* ImportService constructor.
|
||||
*
|
||||
* @param NoteService $noteService
|
||||
* @param UndoService $undoService
|
||||
* @param FollowService $followService
|
||||
* @param AcceptService $acceptService
|
||||
* @param AddService $addService
|
||||
* @param BlockService $blockService
|
||||
* @param CreateService $createService
|
||||
* @param DeleteService $deleteService
|
||||
* @param FollowService $followService
|
||||
* @param NoteService $noteService
|
||||
* @param LikeService $likeService
|
||||
* @param PersonService $personService
|
||||
* @param RejectService $rejectService
|
||||
* @param RemoveService $removeService
|
||||
* @param UndoService $undoService
|
||||
* @param UpdateService $updateService
|
||||
* @param ConfigService $configService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
NoteService $noteService, UndoService $undoService, FollowService $followService,
|
||||
DeleteService $deleteService, ConfigService $configService, MiscService $miscService
|
||||
AcceptService $acceptService, AddService $addService, BlockService $blockService,
|
||||
CreateService $createService, DeleteService $deleteService, FollowService $followService,
|
||||
NoteService $noteService, LikeService $likeService, PersonService $personService,
|
||||
RejectService $rejectService, RemoveService $removeService,
|
||||
UndoService $undoService, UpdateService $updateService,
|
||||
ConfigService $configService, MiscService $miscService
|
||||
) {
|
||||
$this->acceptService = $acceptService;
|
||||
$this->addService = $addService;
|
||||
$this->blockService = $blockService;
|
||||
$this->createService = $createService;
|
||||
$this->deleteService = $deleteService;
|
||||
$this->followService = $followService;
|
||||
$this->likeService = $likeService;
|
||||
$this->rejectService = $rejectService;
|
||||
$this->removeService = $removeService;
|
||||
$this->personService = $personService;
|
||||
$this->noteService = $noteService;
|
||||
$this->undoService = $undoService;
|
||||
$this->followService = $followService;
|
||||
$this->deleteService = $deleteService;
|
||||
$this->updateService = $updateService;
|
||||
$this->configService = $configService;
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
@ -142,6 +205,14 @@ class ImportService {
|
|||
$item = new Accept($root);
|
||||
break;
|
||||
|
||||
case Add::TYPE:
|
||||
$item = new Add($root);
|
||||
break;
|
||||
|
||||
case Block::TYPE:
|
||||
$item = new Block($root);
|
||||
break;
|
||||
|
||||
case Create::TYPE:
|
||||
$item = new Create($root);
|
||||
break;
|
||||
|
@ -158,14 +229,26 @@ class ImportService {
|
|||
$item = new Image($root);
|
||||
break;
|
||||
|
||||
case Like::TYPE:
|
||||
$item = new Like($root);
|
||||
break;
|
||||
|
||||
case Note::TYPE:
|
||||
$item = new Note($root);
|
||||
break;
|
||||
|
||||
case Person::TYPE:
|
||||
$item = new Note($root);
|
||||
break;
|
||||
|
||||
case Reject::TYPE:
|
||||
$item = new Reject($root);
|
||||
break;
|
||||
|
||||
case Remove::TYPE:
|
||||
$item = new Remove($root);
|
||||
break;
|
||||
|
||||
case Tombstone::TYPE:
|
||||
$item = new Tombstone($root);
|
||||
break;
|
||||
|
@ -174,6 +257,10 @@ class ImportService {
|
|||
$item = new Undo($root);
|
||||
break;
|
||||
|
||||
case Update::TYPE:
|
||||
$item = new Update($root);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnknownItemException();
|
||||
}
|
||||
|
@ -206,33 +293,18 @@ class ImportService {
|
|||
*/
|
||||
public function parseIncomingRequest(ACore $activity) {
|
||||
|
||||
if ($activity->gotObject()) {
|
||||
try {
|
||||
$this->parseIncomingRequest($activity->getObject());
|
||||
} catch (UnknownItemException $e) {
|
||||
}
|
||||
}
|
||||
// not sure we need to recursive on activity/parsing.
|
||||
// if ($activity->gotObject()) {
|
||||
// try {
|
||||
// $this->parseIncomingRequest($activity->getObject());
|
||||
// } catch (UnknownItemException $e) {
|
||||
// }
|
||||
// }
|
||||
|
||||
switch ($activity->getType()) {
|
||||
|
||||
case Delete::TYPE:
|
||||
$service = $this->deleteService;
|
||||
break;
|
||||
|
||||
case Follow::TYPE:
|
||||
$service = $this->followService;
|
||||
break;
|
||||
|
||||
case Note::TYPE:
|
||||
$service = $this->noteService;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnknownItemException();
|
||||
}
|
||||
$service = $this->getServiceForItem($activity);
|
||||
|
||||
try {
|
||||
$service->parse($activity);
|
||||
$service->processIncomingRequest($activity, $this);
|
||||
} catch (Exception $e) {
|
||||
$this->miscService->log(
|
||||
'Cannot parse ' . $activity->getType() . ': ' . $e->getMessage()
|
||||
|
@ -244,13 +316,71 @@ class ImportService {
|
|||
/**
|
||||
* @param ACore $activity
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @throws InvalidResourceException
|
||||
* @return ICoreService
|
||||
* @throws UnknownItemException
|
||||
*/
|
||||
public function verifyOrigin(ACore $activity, string $id) {
|
||||
throw new InvalidResourceException();
|
||||
public function getServiceForItem(Acore $activity): ICoreService {
|
||||
switch ($activity->getType()) {
|
||||
|
||||
case Accept::TYPE:
|
||||
$service = $this->acceptService;
|
||||
break;
|
||||
|
||||
case Add::TYPE:
|
||||
$service = $this->addService;
|
||||
break;
|
||||
|
||||
case Block::TYPE:
|
||||
$service = $this->blockService;
|
||||
break;
|
||||
|
||||
case Create::TYPE:
|
||||
$service = $this->createService;
|
||||
break;
|
||||
|
||||
case Delete::TYPE:
|
||||
$service = $this->deleteService;
|
||||
break;
|
||||
|
||||
case Follow::TYPE:
|
||||
$service = $this->followService;
|
||||
break;
|
||||
|
||||
case Like::TYPE:
|
||||
$service = $this->likeService;
|
||||
break;
|
||||
|
||||
case Note::TYPE:
|
||||
$service = $this->noteService;
|
||||
break;
|
||||
|
||||
case Person::TYPE:
|
||||
$service = $this->personService;
|
||||
break;
|
||||
|
||||
case Reject::TYPE:
|
||||
$service = $this->rejectService;
|
||||
break;
|
||||
|
||||
case Remove::TYPE:
|
||||
$service = $this->removeService;
|
||||
break;
|
||||
|
||||
case Undo::TYPE:
|
||||
$service = $this->undoService;
|
||||
break;
|
||||
|
||||
case Update::TYPE:
|
||||
$service = $this->updateService;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnknownItemException();
|
||||
}
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ use OCA\Social\Exceptions\ActorDoesNotExistException;
|
|||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\Post;
|
||||
use OCA\Social\Service\ActivityPub\NoteService;
|
||||
use OCA\Social\Service\ActivityPub\Object\NoteService;
|
||||
|
||||
class PostService {
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue