summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis <6653109+artonge@users.noreply.github.com>2023-01-04 15:19:02 +0100
committerGitHub <noreply@github.com>2023-01-04 15:19:02 +0100
commit990a9aa41f5bc79ee59086d4e8c111825d4d064f (patch)
tree01cdced00c473bc2339408cb4a94db00e52ce33d
parentf945d5fe63888d029e9ae17b57e85ec82cf2edf4 (diff)
Revert "move and delete account"revert-1546-enh/noid/delete-account
-rw-r--r--appinfo/info.xml1
-rw-r--r--lib/Command/AccountDelete.php88
-rw-r--r--lib/Db/ActionsRequest.php26
-rw-r--r--lib/Db/ActionsRequestBuilder.php7
-rw-r--r--lib/Db/CacheActorsRequest.php2
-rw-r--r--lib/Db/CacheActorsRequestBuilder.php4
-rw-r--r--lib/Db/CacheDocumentsRequest.php20
-rw-r--r--lib/Db/CoreRequestBuilder.php13
-rw-r--r--lib/Db/FollowsRequest.php45
-rw-r--r--lib/Db/FollowsRequestBuilder.php9
-rw-r--r--lib/Db/RequestQueueRequest.php19
-rw-r--r--lib/Db/SocialCrossQueryBuilder.php2
-rw-r--r--lib/Db/SocialLimitsQueryBuilder.php6
-rw-r--r--lib/Db/StreamDestRequest.php52
-rw-r--r--lib/Db/StreamDestRequestBuilder.php54
-rw-r--r--lib/Db/StreamRequest.php54
-rw-r--r--lib/Db/StreamTagsRequest.php2
-rw-r--r--lib/Exceptions/StreamDestDoesNotExistException.php33
-rw-r--r--lib/Interfaces/Activity/MoveInterface.php171
-rw-r--r--lib/Interfaces/Actor/PersonInterface.php117
-rw-r--r--lib/Interfaces/Internal/SocialAppNotificationInterface.php2
-rw-r--r--lib/Interfaces/Object/AnnounceInterface.php6
-rw-r--r--lib/Interfaces/Object/LikeInterface.php2
-rw-r--r--lib/Migration/Version1000Date20221118000001.php16
-rw-r--r--lib/Model/ActivityPub/Activity/Move.php62
-rw-r--r--lib/Model/ActivityPub/Item.php12
-rw-r--r--lib/Model/StreamDest.php102
27 files changed, 81 insertions, 846 deletions
diff --git a/appinfo/info.xml b/appinfo/info.xml
index bf032c47..27810482 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -45,7 +45,6 @@
<commands>
<command>OCA\Social\Command\AccountCreate</command>
- <command>OCA\Social\Command\AccountDelete</command>
<command>OCA\Social\Command\AccountFollowing</command>
<command>OCA\Social\Command\CacheRefresh</command>
<command>OCA\Social\Command\CheckInstall</command>
diff --git a/lib/Command/AccountDelete.php b/lib/Command/AccountDelete.php
deleted file mode 100644
index aaad6d9e..00000000
--- a/lib/Command/AccountDelete.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?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\Command;
-
-use Exception;
-use OC\Core\Command\Base;
-use OCA\Social\Interfaces\Actor\PersonInterface;
-use OCA\Social\Service\AccountService;
-use OCA\Social\Service\CacheActorService;
-use OCA\Social\Service\ConfigService;
-use OCP\IUserManager;
-use OCP\Server;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
-
-class AccountDelete extends Base {
- private IUserManager $userManager;
- private AccountService $accountService;
- private CacheActorService $cacheActorService;
- private ConfigService $configService;
-
- public function __construct(
- IUserManager $userManager,
- AccountService $accountService,
- CacheActorService $cacheActorService,
- ConfigService $configService
- ) {
- parent::__construct();
-
- $this->userManager = $userManager;
- $this->accountService = $accountService;
- $this->cacheActorService = $cacheActorService;
- $this->configService = $configService;
- }
-
- protected function configure(): void {
- parent::configure();
- $this->setName('social:account:delete')
- ->addArgument('account', InputArgument::REQUIRED, 'Social Local Account')
- ->setDescription('Delete a local social account');
- }
-
- /**
- * @throws Exception
- */
- protected function execute(InputInterface $input, OutputInterface $output): int {
- $account = $input->getArgument('account');
-
- // TODO: broadcast to other instance
- throw new Exception('not fully available');
-
- $actor = $this->cacheActorService->getFromLocalAccount($account);
- $personInterface = Server::get(PersonInterface::class);
- $personInterface->deleteActor($actor->getId());
-
- return 0;
- }
-}
diff --git a/lib/Db/ActionsRequest.php b/lib/Db/ActionsRequest.php
index 4795c76d..a678a8f6 100644
--- a/lib/Db/ActionsRequest.php
+++ b/lib/Db/ActionsRequest.php
@@ -153,21 +153,13 @@ class ActionsRequest extends ActionsRequestBuilder {
}
- public function deleteByActor(string $actorId): void {
- $qb = $this->getActionsDeleteSql();
- $qb->limitToDBField('actor_id_prim', $qb->prim($actorId));
-
- $qb->executeStatement();
- }
-
-
- public function moveAccount(string $actorId, string $newId): void {
- $qb = $this->getActionsUpdateSql();
- $qb->set('actor_id', $qb->createNamedParameter($newId))
- ->set('actor_id_prim', $qb->createNamedParameter($qb->prim($newId)));
-
- $qb->limitToDBField('actor_id_prim', $qb->prim($actorId));
-
- $qb->executeStatement();
- }
+// /**
+// * @param string $objectId
+// */
+// public function deleteLikes(string $objectId) {
+// $qb = $this->getActionsDeleteSql();
+// $this->limitToObjectId($qb, $objectId);
+//
+// $qb->execute();
+// }
}
diff --git a/lib/Db/ActionsRequestBuilder.php b/lib/Db/ActionsRequestBuilder.php
index 9e068b85..bf139db9 100644
--- a/lib/Db/ActionsRequestBuilder.php
+++ b/lib/Db/ActionsRequestBuilder.php
@@ -31,11 +31,11 @@ declare(strict_types=1);
namespace OCA\Social\Db;
+use OCA\Social\Tools\Exceptions\RowNotFoundException;
+use OCA\Social\Tools\Traits\TArrayTools;
use OCA\Social\Exceptions\ActionDoesNotExistException;
use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Model\ActivityPub\ACore;
-use OCA\Social\Tools\Exceptions\RowNotFoundException;
-use OCA\Social\Tools\Traits\TArrayTools;
/**
* Class ActionsRequestBuilder
@@ -105,8 +105,7 @@ class ActionsRequestBuilder extends CoreRequestBuilder {
*/
protected function getActionsDeleteSql(): SocialQueryBuilder {
$qb = $this->getQueryBuilder();
- $qb->delete(self::TABLE_ACTIONS)
- ->setDefaultSelectAlias('a');
+ $qb->delete(self::TABLE_ACTIONS);
return $qb;
}
diff --git a/lib/Db/CacheActorsRequest.php b/lib/Db/CacheActorsRequest.php
index 520a8250..ecab744e 100644
--- a/lib/Db/CacheActorsRequest.php
+++ b/lib/Db/CacheActorsRequest.php
@@ -241,7 +241,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
*/
public function deleteCacheById(string $id) {
$qb = $this->getCacheActorsDeleteSql();
- $qb->limitToIdPrim($qb->prim($id));
+ $this->limitToIdString($qb, $id);
$qb->execute();
}
diff --git a/lib/Db/CacheActorsRequestBuilder.php b/lib/Db/CacheActorsRequestBuilder.php
index b79e5348..11992cae 100644
--- a/lib/Db/CacheActorsRequestBuilder.php
+++ b/lib/Db/CacheActorsRequestBuilder.php
@@ -96,9 +96,9 @@ class CacheActorsRequestBuilder extends CoreRequestBuilder {
/**
* Base of the Sql Delete request
*
- * @return SocialQueryBuilder
+ * @return IQueryBuilder
*/
- protected function getCacheActorsDeleteSql(): SocialQueryBuilder {
+ protected function getCacheActorsDeleteSql(): IQueryBuilder {
$qb = $this->getQueryBuilder();
$qb->delete(self::TABLE_CACHE_ACTORS);
diff --git a/lib/Db/CacheDocumentsRequest.php b/lib/Db/CacheDocumentsRequest.php
index 88fb20f8..88e6e284 100644
--- a/lib/Db/CacheDocumentsRequest.php
+++ b/lib/Db/CacheDocumentsRequest.php
@@ -56,7 +56,6 @@ class CacheDocumentsRequest extends CacheDocumentsRequestBuilder {
->setValue('local_copy', $qb->createNamedParameter($document->getLocalCopy()))
->setValue('resized_copy', $qb->createNamedParameter($document->getResizedCopy()))
->setValue('parent_id', $qb->createNamedParameter($document->getParentId()))
- ->setValue('parent_id_prim', $qb->createNamedParameter($qb->prim($document->getParentId())))
->setValue('public', $qb->createNamedParameter(($document->isPublic()) ? '1' : '0'));
try {
@@ -84,7 +83,6 @@ class CacheDocumentsRequest extends CacheDocumentsRequestBuilder {
->set('local_copy', $qb->createNamedParameter($document->getLocalCopy()))
->set('resized_copy', $qb->createNamedParameter($document->getResizedCopy()))
->set('parent_id', $qb->createNamedParameter($document->getParentId()))
- ->set('parent_id_prim', $qb->createNamedParameter($qb->prim($document->getParentId())))
->set('public', $qb->createNamedParameter(($document->isPublic()) ? '1' : '0'));
try {
@@ -241,22 +239,4 @@ class CacheDocumentsRequest extends CacheDocumentsRequestBuilder {
$qb->execute();
}
-
- public function deleteByParent(string $parentId): void {
- $qb = $this->getCacheDocumentsDeleteSql();
- $qb->limitToDBField('parent_id_prim', $qb->prim($parentId));
-
- $qb->executeStatement();
- }
-
-
- public function moveAccount(string $actorId, string $newId): void {
- $qb = $this->getCacheDocumentsUpdateSql();
- $qb->set('parent_id', $qb->createNamedParameter($newId))
- ->set('parent_id_prim', $qb->createNamedParameter($qb->prim($newId)));
-
- $qb->limitToDBField('parent_id_prim', $qb->prim($actorId));
-
- $qb->executeStatement();
- }
}
diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php
index 99fe2289..a7c93c11 100644
--- a/lib/Db/CoreRequestBuilder.php
+++ b/lib/Db/CoreRequestBuilder.php
@@ -36,7 +36,6 @@ use DateTime;
use Doctrine\DBAL\Query\QueryBuilder;
use Exception;
use OC;
-use OC\DB\Connection;
use OC\DB\SchemaWrapper;
use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Model\ActivityPub\Actor\Person;
@@ -1264,10 +1263,10 @@ class CoreRequestBuilder {
* this just empty all tables from the app.
*/
public function emptyAll() {
- $schema = new SchemaWrapper(Server::get(Connection::class));
+ $schema = new SchemaWrapper(Server::get(IDBConnection::class));
foreach (array_keys(self::$tables) as $table) {
if ($schema->hasTable($table)) {
- $qb = $this->getQueryBuilder();
+ $qb = $this->dbConnection->getQueryBuilder();
$qb->delete($table);
$qb->execute();
}
@@ -1279,7 +1278,7 @@ class CoreRequestBuilder {
* this just empty all tables from the app.
*/
public function uninstallSocialTables() {
- $schema = new SchemaWrapper(Server::get(Connection::class));
+ $schema = new SchemaWrapper(Server::get(IDBConnection::class));
foreach (array_keys(self::$tables) as $table) {
if ($schema->hasTable($table)) {
$schema->dropTable($table);
@@ -1294,7 +1293,7 @@ class CoreRequestBuilder {
*
*/
public function uninstallFromMigrations() {
- $qb = $this->getQueryBuilder();
+ $qb = $this->dbConnection->getQueryBuilder();
$qb->delete('migrations');
$qb->where($this->exprLimitToDBField($qb, 'app', 'social', true, true));
@@ -1305,12 +1304,12 @@ class CoreRequestBuilder {
*
*/
public function uninstallFromJobs() {
- $qb = $this->getQueryBuilder();
+ $qb = $this->dbConnection->getQueryBuilder();
$qb->delete('jobs');
$qb->where($this->exprLimitToDBField($qb, 'class', 'OCA\Social\Cron\Cache', true, true));
$qb->execute();
- $qb = $this->getQueryBuilder();
+ $qb = $this->dbConnection->getQueryBuilder();
$qb->delete('jobs');
$qb->where($this->exprLimitToDBField($qb, 'class', 'OCA\Social\Cron\Queue', true, true));
$qb->execute();
diff --git a/lib/Db/FollowsRequest.php b/lib/Db/FollowsRequest.php
index 43a7643e..7c799dab 100644
--- a/lib/Db/FollowsRequest.php
+++ b/lib/Db/FollowsRequest.php
@@ -31,12 +31,12 @@ declare(strict_types=1);
namespace OCA\Social\Db;
+use OCA\Social\Tools\Traits\TArrayTools;
use DateTime;
use Exception;
use OCA\Social\Exceptions\FollowNotFoundException;
use OCA\Social\Model\ActivityPub\Actor\Person;
use OCA\Social\Model\ActivityPub\Object\Follow;
-use OCA\Social\Tools\Traits\TArrayTools;
use OCP\DB\QueryBuilder\IQueryBuilder;
/**
@@ -285,10 +285,13 @@ class FollowsRequest extends FollowsRequestBuilder {
*/
public function deleteRelatedId(string $actorId) {
$qb = $this->getFollowsDeleteSql();
- $orX = $qb->expr()->orX();
- $orX->add($qb->exprLimitToDBField('actor_id_prim', $qb->prim($actorId)));
- $orX->add($qb->exprLimitToDBField('object_id_prim', $qb->prim($actorId)));
- $qb->where($orX);
+ $this->limitToActorId($qb, $actorId);
+
+ $qb->execute();
+
+ $qb = $this->getFollowsDeleteSql();
+ $this->limitToObjectId($qb, $actorId);
+
$qb->execute();
}
@@ -301,36 +304,4 @@ class FollowsRequest extends FollowsRequestBuilder {
$qb->execute();
}
-
-
- /**
- * @param string $actorId
- * @param Person $new
- */
- public function moveAccountFollowers(string $actorId, Person $new): void {
- $qb = $this->getFollowsUpdateSql();
- $qb->set('object_id', $qb->createNamedParameter($new->getId()))
- ->set('object_id_prim', $qb->createNamedParameter($qb->prim($new->getId())))
- ->set('follow_id', $qb->createNamedParameter($new->getFollowers()))
- ->set('follow_id_prim', $qb->createNamedParameter($qb->prim($new->getFollowers())));
-
- $qb->limitToObjectIdPrim($qb->prim($actorId));
-
- $qb->executeStatement();
- }
-
-
- /**
- * @param string $actorId
- * @param Person $new
- */
- public function moveAccountFollowing(string $actorId, Person $new): void {
- $qb = $this->getFollowsUpdateSql();
- $qb->set('actor_id', $qb->createNamedParameter($new->getId()))
- ->set('actor_id_prim', $qb->createNamedParameter($qb->prim($new->getId())));
-
- $qb->limitToActorIdPrim($qb->prim($actorId));
-
- $qb->executeStatement();
- }
}
diff --git a/lib/Db/FollowsRequestBuilder.php b/lib/Db/FollowsRequestBuilder.php
index a7918c72..a2d2b82e 100644
--- a/lib/Db/FollowsRequestBuilder.php
+++ b/lib/Db/FollowsRequestBuilder.php
@@ -36,6 +36,7 @@ use OCA\Social\Tools\Traits\TArrayTools;
use OCA\Social\Exceptions\FollowNotFoundException;
use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Model\ActivityPub\Object\Follow;
+use OCP\DB\QueryBuilder\IQueryBuilder;
/**
* Class FollowsRequestBuilder
@@ -62,9 +63,9 @@ class FollowsRequestBuilder extends CoreRequestBuilder {
/**
* Base of the Sql Update request
*
- * @return SocialQueryBuilder
+ * @return IQueryBuilder
*/
- protected function getFollowsUpdateSql(): SocialQueryBuilder {
+ protected function getFollowsUpdateSql(): IQueryBuilder {
$qb = $this->getQueryBuilder();
$qb->update(self::TABLE_FOLLOWS);
@@ -113,9 +114,9 @@ class FollowsRequestBuilder extends CoreRequestBuilder {
/**
* Base of the Sql Delete request
*
- * @return SocialQueryBuilder
+ * @return IQueryBuilder
*/
- protected function getFollowsDeleteSql(): SocialQueryBuilder {
+ protected function getFollowsDeleteSql(): IQueryBuilder {
$qb = $this->getQueryBuilder();
$qb->delete(self::TABLE_FOLLOWS);
diff --git a/lib/Db/RequestQueueRequest.php b/lib/Db/RequestQueueRequest.php
index 7ee48257..4da8fbe2 100644
--- a/lib/Db/RequestQueueRequest.php
+++ b/lib/Db/RequestQueueRequest.php
@@ -47,7 +47,6 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
* Create a new Queue in the database.
*
* @param RequestQueue[] $queues
- *
* @throws Exception
*/
public function multiple(array $queues): void {
@@ -65,7 +64,6 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
$qb = $this->getRequestQueueInsertSql();
$qb->setValue('token', $qb->createNamedParameter($queue->getToken()))
->setValue('author', $qb->createNamedParameter($queue->getAuthor()))
- ->setValue('author_prim', $qb->createNamedParameter($qb->prim($queue->getAuthor())))
->setValue('activity', $qb->createNamedParameter($queue->getActivity()))
->setValue(
'instance', $qb->createNamedParameter(
@@ -199,21 +197,4 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
$qb->executeStatement();
}
-
- public function deleteByAuthor(string $actorId): void {
- $qb = $this->getRequestQueueDeleteSql();
- $qb->limitToDBField('author_prim', $qb->prim($actorId));
-
- $qb->executeStatement();
- }
-
-// public function moveAccount(string $actorId, string $newId, string $instance): void {
-// $qb = $this->getRequestQueueUpdateSql();
-// $qb->set('author', $qb->createNamedParameter($newId))
-// ->set('author_prim', $qb->createNamedParameter($qb->prim($newId)))
-// ->set('instance', $qb->createNamedParameter($instance));
-// $qb->limitToDBField('author_prim', $qb->prim($actorId));
-//
-// $qb->execute();
-// }
}
diff --git a/lib/Db/SocialCrossQueryBuilder.php b/lib/Db/SocialCrossQueryBuilder.php
index 239e0404..3bc16b12 100644
--- a/lib/Db/SocialCrossQueryBuilder.php
+++ b/lib/Db/SocialCrossQueryBuilder.php
@@ -293,7 +293,7 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
* @param string $aliasDest
* @param string $alias
*/
- public function innerJoinStreamDest(
+ public function innerJoinSteamDest(
string $type, string $field = 'id_prim', string $aliasDest = 'sd', string $alias = ''
) {
$this->andWhere($this->exprInnerJoinStreamDest($type, $field, $aliasDest, $alias));
diff --git a/lib/Db/SocialLimitsQueryBuilder.php b/lib/Db/SocialLimitsQueryBuilder.php
index 88bc4369..e025c740 100644
--- a/lib/Db/SocialLimitsQueryBuilder.php
+++ b/lib/Db/SocialLimitsQueryBuilder.php
@@ -189,7 +189,7 @@ class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder {
* @param string $alias
*/
public function limitToActorIdPrim(string $actorId, string $alias = '') {
- $this->limitToDBField('actor_id_prim', $actorId, false, $alias);
+ $this->limitToDBField('actor_id', $actorId, false, $alias);
}
@@ -278,7 +278,7 @@ class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder {
*/
public function limitToAttributedTo(string $actorId, bool $prim = false) {
if ($prim) {
- $this->limitToDBField('attributed_to_prim', $this->prim($actorId));
+ $this->limitToDBField('attributed_to_prim', $this->prim($actorId), false);
return;
}
@@ -437,7 +437,7 @@ class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder {
) {
if (!$this->hasViewer()) {
$this->selectDestFollowing($aliasDest);
- $this->innerJoinStreamDest('recipient', 'id_prim', 'sd', 's');
+ $this->innerJoinSteamDest('recipient', 'id_prim', 'sd', 's');
$this->limitToDest(ACore::CONTEXT_PUBLIC, 'recipient', '', $aliasDest);
return;
diff --git a/lib/Db/StreamDestRequest.php b/lib/Db/StreamDestRequest.php
index 2281d9d9..95f23758 100644
--- a/lib/Db/StreamDestRequest.php
+++ b/lib/Db/StreamDestRequest.php
@@ -31,16 +31,14 @@ declare(strict_types=1);
namespace OCA\Social\Db;
+use OCA\Social\Tools\Traits\TStringTools;
use Exception;
-use OCA\Social\Model\ActivityPub\Actor\Person;
+use OCP\DB\Exception as DBException;
use OCA\Social\Model\ActivityPub\Internal\SocialAppNotification;
use OCA\Social\Model\ActivityPub\Stream;
-use OCA\Social\Model\StreamDest;
use OCA\Social\Service\CacheActorService;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\MiscService;
-use OCA\Social\Tools\Traits\TStringTools;
-use OCP\DB\Exception as DBException;
use OCP\IDBConnection;
use OCP\IURLGenerator;
use Psr\Log\LoggerInterface;
@@ -56,8 +54,7 @@ class StreamDestRequest extends StreamDestRequestBuilder {
private CacheActorService $cacheActorService;
public function __construct(
- IDBConnection $connection, LoggerInterface $logger, IURLGenerator $urlGenerator,
- CacheActorService $cacheActorService,
+ IDBConnection $connection, LoggerInterface $logger, IURLGenerator $urlGenerator, CacheActorService $cacheActorService,
ConfigService $configService, MiscService $miscService
) {
parent::__construct($connection, $logger, $urlGenerator, $configService, $miscService);
@@ -156,50 +153,9 @@ class StreamDestRequest extends StreamDestRequestBuilder {
}
public function emptyStreamDest(): void {
- $qb = $this->getQueryBuilder();
+ $qb = $this->dbConnection->getQueryBuilder();
$qb->delete(self::TABLE_STREAM_DEST);
$qb->executeStatement();
}
-
-
- /**
- * @param string $actorId
- *
- * @return StreamDest[]
- */
- public function getRelatedToActor(Person $actor): array {
- $qb = $this->getStreamDestSelectSql();
- $orX = $qb->expr()->orX();
- $orX->add($qb->exprLimitToDBField('actor_id', $qb->prim($actor->getId())));
- $orX->add($qb->exprLimitToDBField('actor_id', $qb->prim($actor->getFollowers())));
- $orX->add($qb->exprLimitToDBField('actor_id', $qb->prim($actor->getFollowing())));
- $qb->where($orX);
-
- return $this->getStreamDestsFromRequest($qb);
- }
-
-
- /**
- * @param string $actorId
- */
- public function deleteRelatedToActor(string $actorId): void {
- $qb = $this->getStreamDestDeleteSql();
- $qb->limitToActorId($qb->prim($actorId));
-
- $qb->executeStatement();
- }
-
-
-
- /**
- * @param string $actorId
- */
- public function moveActor(string $actorId, string $newId): void {
- $qb = $this->getStreamDestUpdateSql();
- $qb->set('actor_id', $qb->createNamedParameter($qb->prim($newId)));
- $qb->limitToActorId($qb->prim($actorId));
-
- $qb->executeStatement();
- }
}
diff --git a/lib/Db/StreamDestRequestBuilder.php b/lib/Db/StreamDestRequestBuilder.php
index 5087b6a0..61bac94e 100644
--- a/lib/Db/StreamDestRequestBuilder.php
+++ b/lib/Db/StreamDestRequestBuilder.php
@@ -30,10 +30,8 @@ declare(strict_types=1);
namespace OCA\Social\Db;
-use OCA\Social\Exceptions\StreamDestDoesNotExistException;
-use OCA\Social\Model\StreamDest;
-use OCA\Social\Tools\Exceptions\RowNotFoundException;
use OCA\Social\Tools\Traits\TArrayTools;
+use OCP\DB\QueryBuilder\IQueryBuilder;
/**
* Class StreamDestRequestBuilder
@@ -58,9 +56,9 @@ class StreamDestRequestBuilder extends CoreRequestBuilder {
/**
* Base of the Sql Update request
*
- * @return SocialQueryBuilder
+ * @return IQueryBuilder
*/
- protected function getStreamDestUpdateSql(): SocialQueryBuilder {
+ protected function getStreamDestUpdateSql(): IQueryBuilder {
$qb = $this->getQueryBuilder();
$qb->update(self::TABLE_STREAM_DEST);
@@ -77,7 +75,7 @@ class StreamDestRequestBuilder extends CoreRequestBuilder {
$qb = $this->getQueryBuilder();
/** @noinspection PhpMethodParametersCountMismatchInspection */
- $qb->select('sd.actor_id', 'sd.stream_id', 'sd.type', 'sd.subtype')
+ $qb->select('sd.actor_id', 'sd.stream_id', 'sd.type')
->from(self::TABLE_STREAM_DEST, 'sd');
$this->defaultSelectAlias = 'sd';
@@ -90,9 +88,9 @@ class StreamDestRequestBuilder extends CoreRequestBuilder {
/**
* Base of the Sql Delete request
*
- * @return SocialQueryBuilder
+ * @return IQueryBuilder
*/
- protected function getStreamDestDeleteSql(): SocialQueryBuilder {
+ protected function getStreamDestDeleteSql(): IQueryBuilder {
$qb = $this->getQueryBuilder();
$qb->delete(self::TABLE_STREAM_DEST);
@@ -115,44 +113,4 @@ class StreamDestRequestBuilder extends CoreRequestBuilder {
return $qb;
}
-
-
- /**
- * @param SocialQueryBuilder $qb
- *
- * @return StreamDest
- * @throws StreamDestDoesNotExistException
- */
- public function getStreamDestFromRequest(SocialQueryBuilder $qb): StreamDest {
- /** @var StreamDest $result */
- try {
- $result = $qb->getRow([$this, 'parseStreamDestSelectSql']);
- } catch (RowNotFoundException $e) {
- throw new StreamDestDoesNotExistException();
- }
-
- return $result;
- }
-
- /**
- * @param SocialQueryBuilder $qb
- *
- * @return StreamDest[]
- */
- public function getStreamDestsFromRequest(SocialQueryBuilder $qb): array {
- return $qb->getRows([$this, 'parseStreamDestSelectSql']);
- }
-
-
- /