rewrite sql to use ExtendedQueryBuilder

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
feature/noid/sql-rewrite-0929^2
Maxence Lange 2019-09-29 17:41:47 +02:00
rodzic 7f02c662f6
commit fbe4ea9012
11 zmienionych plików z 171 dodań i 185 usunięć

Wyświetl plik

@ -31,6 +31,7 @@ declare(strict_types=1);
namespace OCA\Social\Db;
use daita\MySmallPhpTools\Exceptions\DateTimeException;
use DateInterval;
use DateTime;
use Doctrine\DBAL\Query\QueryBuilder;
@ -38,7 +39,6 @@ use Exception;
use OC;
use OC\DB\SchemaWrapper;
use OCA\Social\AP;
use OCA\Social\Exceptions\DateTimeException;
use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Model\ActivityPub\Actor\Person;
use OCA\Social\Model\ActivityPub\Object\Document;
@ -236,7 +236,7 @@ class CoreRequestBuilder {
/**
* Limit the request to the Id (string)
*
* @deprecated
* @param IQueryBuilder $qb
* @param string $id
*/
@ -803,24 +803,6 @@ class CoreRequestBuilder {
}
/**
* @param IQueryBuilder $qb
* @param string $alias
*/
protected function selectStreamActions(IQueryBuilder &$qb, string $alias = 'sa') {
if ($qb->getType() !== QueryBuilder::SELECT) {
return;
}
$pf = (($alias === '') ? $this->defaultSelectAlias : $alias);
$qb->from(self::TABLE_STREAM_ACTIONS, $pf);
$qb->selectAlias('sa.id', 'streamaction_id')
->selectAlias('sa.actor_id', 'streamaction_actor_id')
->selectAlias('sa.stream_id', 'streamaction_stream_id')
->selectAlias('sa.values', 'streamaction_values');
}
/**
* @param IQueryBuilder $qb
* @param string $fieldActorId

Wyświetl plik

@ -32,6 +32,8 @@ namespace OCA\Social\Db;
use Doctrine\DBAL\Query\QueryBuilder;
use OCP\DB\QueryBuilder\ICompositeExpression;
use OCP\DB\QueryBuilder\IQueryBuilder;
/**
@ -62,8 +64,9 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
/**
* @param string $alias
* @param string $link
*/
public function selectCacheActors(string $alias = 'ca') {
public function innerJoinCacheActors(string $alias = 'ca', string $link = '') {
if ($this->getType() !== QueryBuilder::SELECT) {
return;
}
@ -87,6 +90,12 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
->selectAlias($pf . '.source', 'cacheactor_source')
->selectAlias($pf . '.creation', 'cacheactor_creation')
->selectAlias($pf . '.local', 'cacheactor_local');
if ($link !== '') {
$expr = $this->expr();
$this->andWhere($expr->eq('ca.id_prim', $link));
}
}
@ -113,6 +122,24 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
}
/**
* @param IQueryBuilder $qb
* @param string $alias
*/
public function selectStreamActions(string $alias = 'sa') {
if ($this->getType() !== QueryBuilder::SELECT) {
return;
}
$pf = (($alias === '') ? $this->getDefaultSelectAlias() : $alias);
$this->from(CoreRequestBuilder::TABLE_STREAM_ACTIONS, $pf);
$this->selectAlias('sa.id', 'streamaction_id')
->selectAlias('sa.actor_id', 'streamaction_actor_id')
->selectAlias('sa.stream_id', 'streamaction_stream_id')
->selectAlias('sa.values', 'streamaction_values');
}
/**
* @param string $alias
*/
@ -151,11 +178,13 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
* @param string $aliasDest
* @param string $aliasFollowing
* @param string $alias
*
* @return ICompositeExpression
*/
public function innerJoinDestFollowing(
string $actorId, string $type, string $field = 'id_prim', string $aliasDest = 'sd',
string $aliasFollowing = 'f', string $alias = ''
) {
): ICompositeExpression {
$expr = $this->expr();
$andX = $expr->andX();
$pf = (($alias === '') ? $this->getdefaultSelectAlias() : $alias) . '.';
@ -167,7 +196,7 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
$andX->add($expr->eq($aliasDest . '.stream_id', $pf . $field));
$andX->add($expr->eq($aliasDest . '.type', $this->createNamedParameter($type)));
$this->andWhere($andX);
return $andX;
}
}

Wyświetl plik

@ -31,11 +31,12 @@ declare(strict_types=1);
namespace OCA\Social\Db;
use daita\MySmallPhpTools\Exceptions\DateTimeException;
use DateInterval;
use DateTime;
use Exception;
use OCA\Social\Exceptions\DateTimeException;
use OCA\Social\Model\ActivityPub\ACore;
use OCP\DB\QueryBuilder\ICompositeExpression;
/**
@ -53,7 +54,7 @@ class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder {
* @return SocialQueryBuilder
*/
public function limitToType(string $type): self {
$this->limitToDBField('type', $type, false);
$this->limitToDBField('type', $type, true);
return $this;
}
@ -233,8 +234,15 @@ class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder {
* Limit the request to the url
*
* @param string $actorId
* @param bool $prim
*/
public function limitToAttributedTo(string $actorId) {
public function limitToAttributedTo(string $actorId, bool $prim = false) {
if ($prim) {
$this->limitToDBField('attributed_to_prim', $this->prim($actorId), false);
return;
}
$this->limitToDBField('attributed_to', $actorId, false);
}
@ -309,20 +317,42 @@ class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder {
* @param string $alias
*/
public function limitToDest(string $actorId, string $type, string $subType = '', string $alias = 'sd') {
$this->limitToDBField('actor_id', $this->prim($actorId), true, $alias);
$this->limitToDBField('type', $type, true, $alias);
$this->andWhere($this->exprLimitToDest($actorId, $type, $subType, $alias));
}
/**
* @param string $actorId
* @param string $type
* @param string $subType
* @param string $alias
*
* @return ICompositeExpression
*/
public function exprLimitToDest(string $actorId, string $type, string $subType = '', string $alias = 'sd'
): ICompositeExpression {
$expr = $this->expr();
$andX = $expr->andX();
$andX->add($expr->eq($alias . '.stream_id', $this->getDefaultSelectAlias() . '.id_prim'));
$andX->add($this->exprLimitToDBField('actor_id', $this->prim($actorId), true, true, $alias));
$andX->add($this->exprLimitToDBField('type', $type, true, true, $alias));
if ($subType !== '') {
$this->limitToDBField('subtype', $subType, true, $alias);
$andX->add($this->exprLimitToDBField('subtype', $subType, true, true, $alias));
}
return $andX;
}
/**
* @param string $aliasDest
* @param string $aliasFollowing
* @param bool $public
*/
public function limitToViewer(string $aliasDest = 'sd', string $aliasFollowing = 'f') {
public function limitToViewer(string $aliasDest = 'sd', string $aliasFollowing = 'f', bool $public = false
) {
if (!$this->hasViewer()) {
$this->selectDestFollowing($aliasDest);
$this->limitToDest(ACore::CONTEXT_PUBLIC, 'recipient', '', $aliasDest);
@ -330,9 +360,21 @@ class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder {
return;
}
$actor = $this->getViewer();
$this->selectDestFollowing($aliasDest, $aliasFollowing);
$this->innerJoinDestFollowing($actor->getId(), 'recipient', 'id_prim', $aliasDest, $aliasFollowing);
$expr = $this->expr();
$orX = $expr->orX();
$actor = $this->getViewer();
$following = $this->innerJoinDestFollowing(
$actor->getId(), 'recipient', 'id_prim', $aliasDest, $aliasFollowing
);
$orX->add($following);
if ($public) {
$orX->add($this->exprLimitToDest(ACore::CONTEXT_PUBLIC, 'recipient', '', $aliasDest));
}
$this->andWhere($orX);
}
}

Wyświetl plik

@ -65,29 +65,31 @@ class StreamDestRequest extends StreamDestRequestBuilder {
* @param Stream $stream
*/
public function generateStreamDest(Stream $stream) {
$recipients = array_merge(
$stream->getToAll(), $stream->getCcArray(), $stream->getBccArray(),
[$stream->getAttributedTo()]
);
$recipients =
[
'to' => array_merge($stream->getToAll(), [$stream->getAttributedTo()]),
'cc' => array_merge($stream->getCcArray(), $stream->getBccArray())
];
$streamId = $this->prim($stream->getId());
foreach ($recipients as $actorId) {
if ($actorId === '') {
continue;
foreach (array_keys($recipients) as $subtype) {
foreach ($recipients[$subtype] as $actorId) {
if ($actorId === '') {
continue;
}
$qb = $this->getStreamDestInsertSql();
$streamId = $qb->prim($stream->getId());
$qb->setValue('stream_id', $qb->createNamedParameter($streamId));
$qb->setValue('actor_id', $qb->createNamedParameter($qb->prim($actorId)));
$qb->setValue('type', $qb->createNamedParameter('recipient'));
$qb->setValue('subtype', $qb->createNamedParameter($subtype));
try {
$qb->execute();
} catch (UniqueConstraintViolationException $e) {
\OC::$server->getLogger()
->log(3, 'Social - Duplicate recipient on Stream ' . json_encode($stream));
}
}
$qb = $this->getStreamDestInsertSql();
$qb->setValue('stream_id', $qb->createNamedParameter($streamId));
$qb->setValue('actor_id', $qb->createNamedParameter($this->prim($actorId)));
$qb->setValue('type', $qb->createNamedParameter('recipient'));
try {
$qb->execute();
} catch (UniqueConstraintViolationException $e) {
\OC::$server->getLogger()
->log(3, 'Social - Duplicate recipient on Stream ' . json_encode($stream));
}
}
}

Wyświetl plik

@ -50,8 +50,8 @@ class StreamDestRequestBuilder extends CoreRequestBuilder {
*
* @return IQueryBuilder
*/
protected function getStreamDestInsertSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder();
protected function getStreamDestInsertSql(): SocialQueryBuilder {
$qb = $this->getQueryBuilder();
$qb->insert(self::TABLE_STREAM_DEST);
return $qb;

Wyświetl plik

@ -30,13 +30,13 @@ declare(strict_types=1);
namespace OCA\Social\Db;
use daita\MySmallPhpTools\Exceptions\DateTimeException;
use daita\MySmallPhpTools\Model\Cache;
use DateTime;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\Query\QueryBuilder;
use Exception;
use OCA\Social\Exceptions\DateTimeException;
use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\StreamNotFoundException;
use OCA\Social\Model\ActivityPub\ACore;
@ -109,8 +109,6 @@ class StreamRequest extends StreamRequestBuilder {
/**
* @param Stream $stream \
*
* @return Statement|int
*/
public function update(Stream $stream) {
$qb = $this->getStreamUpdateSql();
@ -122,9 +120,9 @@ class StreamRequest extends StreamRequestBuilder {
)
);
$qb->limitToIdPrim($qb->prim($stream->getId()));
$qb->execute();
// TODO - update StreamDest !???
return $qb->execute();
$this->streamDestRequest->generateStreamDest($stream);
}
@ -236,11 +234,10 @@ class StreamRequest extends StreamRequestBuilder {
$expr = $qb->expr();
$qb->limitToIdPrim($qb->prim($id));
$qb->selectCacheActors('ca');
$qb->andWhere($expr->eq('s.attributed_to_prim', 'ca.id_prim'));
$qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
if ($asViewer) {
$qb->limitToViewer('sd', 'f');
$qb->limitToViewer('sd', 'f', true);
$qb->leftJoinStreamAction('sa');
}
@ -273,13 +270,17 @@ class StreamRequest extends StreamRequestBuilder {
};
$qb = $this->getStreamSelectSql();
$this->limitToInReplyTo($qb, $id);
$this->limitPaginate($qb, $since, $limit);
$this->leftJoinCacheActors($qb, 'attributed_to');
$qb->limitToInReplyTo($id);
$qb->limitPaginate($since, $limit);
$expr = $qb->expr();
$qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
$qb->andWhere($expr->eq('s.attributed_to', 'ca.id_prim'));
if ($asViewer) {
$this->limitToViewer($qb);
$this->leftJoinStreamAction($qb);
$qb->limitToViewer('sd', 'f', true);
$qb->leftJoinStreamAction();
}
return $this->getStreamsFromRequest($qb);
@ -299,7 +300,7 @@ class StreamRequest extends StreamRequestBuilder {
};
$qb = $this->getStreamSelectSql();
$this->limitToActivityId($qb, $id);
$qb->limitToActivityId($id);
return $this->getStreamFromRequest($qb);
}
@ -320,9 +321,9 @@ class StreamRequest extends StreamRequestBuilder {
};
$qb = $this->getStreamSelectSql();
$this->limitToObjectId($qb, $objectId);
$qb->limitToObjectId($objectId);
$qb->limitToType($type);
$this->limitToSubType($qb, $subType);
$qb->limitToSubType($subType);
return $this->getStreamFromRequest($qb);
}
@ -335,8 +336,9 @@ class StreamRequest extends StreamRequestBuilder {
*/
public function countNotesFromActorId(string $actorId): int {
$qb = $this->countNotesSelectSql();
$this->limitToAttributedTo($qb, $actorId);
$qb->limitToAttributedTo($qb->prim($actorId), true);
$qb->limitToType(Note::TYPE);
// TODO rewrite this !
$this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC);
$cursor = $qb->execute();
@ -363,16 +365,11 @@ class StreamRequest extends StreamRequestBuilder {
$qb = $this->getStreamSelectSql();
$expr = $qb->expr();
$qb->selectCacheActors('ca');
$qb->innerJoinCacheActors('ca', 'f.object_id_prim');
$qb->limitPaginate($since, $limit);
$qb->andWhere($qb->exprLimitToDBField('type', SocialAppNotification::TYPE, false));
$qb->limitToViewer('sd', 'f');
// $qb->selectDestFollowing('sd', 'f');
// $qb->andWhere($qb->exprInnerJoinDestFollowing($actor, 'recipient', 'id_prim', 'sd', 'f'));
//
$qb->limitToViewer('sd', 'f', false);
$qb->andWhere($expr->eq('f.object_id_prim', 'ca.id_prim'));
$qb->leftJoinStreamAction('sa');
@ -400,12 +397,12 @@ class StreamRequest extends StreamRequestBuilder {
public function getTimelineNotifications(Person $actor, int $since = 0, int $limit = 5): array {
$qb = $this->getStreamSelectSql();
$this->limitPaginate($qb, $since, $limit);
$qb->limitPaginate($since, $limit);
$this->limitToRecipient($qb, $actor->getId(), false);
$qb->limitToType(SocialAppNotification::TYPE);
$this->leftJoinCacheActors($qb, 'attributed_to');
$this->leftJoinStreamAction($qb);
$qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
$qb->leftJoinStreamAction();
return $this->getStreamsFromRequest($qb);
}
@ -425,13 +422,13 @@ class StreamRequest extends StreamRequestBuilder {
*/
public function getTimelineAccount(string $actorId, int $since = 0, int $limit = 5): array {
$qb = $this->getStreamSelectSql();
$this->limitPaginate($qb, $since, $limit);
$qb->limitPaginate($since, $limit);
$this->limitToAttributedTo($qb, $actorId);
$qb->limitToAttributedTo($actorId);
$this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC);
$this->leftJoinCacheActors($qb, 'attributed_to');
$this->leftJoinStreamAction($qb);
$qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
$qb->leftJoinStreamAction();
return $this->getStreamsFromRequest($qb);
}
@ -451,15 +448,15 @@ class StreamRequest extends StreamRequestBuilder {
*/
public function getTimelineDirect(Person $actor, int $since = 0, int $limit = 5): array {
$qb = $this->getStreamSelectSql();
$this->limitPaginate($qb, $since, $limit);
$qb->limitPaginate($since, $limit);
$this->limitToRecipient($qb, $actor->getId(), true);
$this->filterRecipient($qb, ACore::CONTEXT_PUBLIC);
$this->filterRecipient($qb, $actor->getFollowers());
$this->filterType($qb, SocialAppNotification::TYPE);
$qb->filterType(SocialAppNotification::TYPE);
// $this->filterHiddenOnTimeline($qb);
$this->leftJoinCacheActors($qb, 'attributed_to');
$qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
return $this->getStreamsFromRequest($qb);
}
@ -479,17 +476,19 @@ class StreamRequest extends StreamRequestBuilder {
public function getTimelineGlobal(int $since = 0, int $limit = 5, bool $localOnly = true
): array {
$qb = $this->getStreamSelectSql();
$this->limitPaginate($qb, $since, $limit);
$qb->limitPaginate($since, $limit);
$this->limitToLocal($qb, $localOnly);
$qb->limitToLocal($localOnly);
$qb->limitToType(Note::TYPE);
$this->leftJoinCacheActors($qb, 'attributed_to');
$this->leftJoinStreamAction($qb);
$qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
$qb->leftJoinStreamAction();
// TODO: to: = real public, cc: = unlisted !?
// DO NOT USE stream_dest.type = 'recipient' on this one !
$this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC, true, ['to']);
// USE stream_dest.type = 'recipient' and stream_dest.subtype='to' on this one !
$qb->selectDestFollowing('sd', '');
$qb->limitToDest(ACore::CONTEXT_PUBLIC, 'recipient', 'to', 'sd');
// $this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC, true, ['to']);
return $this->getStreamsFromRequest($qb);
}
@ -506,23 +505,22 @@ class StreamRequest extends StreamRequestBuilder {
* @throws DateTimeException
*/
public function getTimelineLiked(int $since = 0, int $limit = 5): array {
if ($this->viewer === null) {
$qb = $this->getStreamSelectSql();
if (!$qb->hasViewer()) {
return [];
}
$actorId = $this->viewer->getId();
$actor = $qb->getViewer();
$qb = $this->getStreamSelectSql();
$qb->limitToType(Note::TYPE);
$this->limitPaginate($qb, $since, $limit);
$qb->limitPaginate($since, $limit);
$expr = $qb->expr();
$this->selectCacheActors($qb, 'ca');
$qb->andWhere($expr->eq('s.attributed_to_prim', 'ca.id_prim'));
$qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
$this->selectStreamActions($qb, 'sa');
$qb->selectStreamActions('sa');
$qb->andWhere($expr->eq('sa.stream_id_prim', 's.id_prim'));
$qb->andWhere($expr->eq('sa.actor_id_prim', $qb->createNamedParameter($this->prim($actorId))));
$qb->andWhere($expr->eq('sa.actor_id_prim', $qb->createNamedParameter($qb->prim($actor->getId()))));
$qb->andWhere($expr->eq('sa.liked', $qb->createNamedParameter(1)));
return $this->getStreamsFromRequest($qb);
@ -547,6 +545,7 @@ class StreamRequest extends StreamRequestBuilder {
): array {
$qb = $this->getStreamSelectSql();
// TODO - rewrite the whole method ?
$on = $this->exprJoinFollowing($qb, $actor);
$on->add($this->exprLimitToRecipient($qb, ACore::CONTEXT_PUBLIC, false));
$on->add($this->exprLimitToRecipient($qb, $actor->getId(), true));
@ -554,7 +553,7 @@ class StreamRequest extends StreamRequestBuilder {
$qb->andWhere($this->exprValueWithinJsonFormat($qb, 'hashtags', '' . $hashtag));
$this->limitPaginate($qb, $since, $limit);
$qb->limitPaginate($since, $limit);
// $this->filterHiddenOnTimeline($qb);
$this->leftJoinCacheActors($qb, 'attributed_to');
@ -572,9 +571,9 @@ class StreamRequest extends StreamRequestBuilder {
*/
public function getNoteSince(int $since): array {
$qb = $this->getStreamSelectSql();
$this->limitToSince($qb, $since, 'published_time');
$qb->limitToSince($since, 'published_time');
$qb->limitToType(Note::TYPE);
$this->leftJoinStreamAction($qb);
$qb->leftJoinStreamAction();
return $this->getStreamsFromRequest($qb);
}
@ -601,7 +600,7 @@ class StreamRequest extends StreamRequestBuilder {
*/
public function deleteByAuthor(string $actorId) {
$qb = $this->getStreamDeleteSql();
$this->limitToAttributedTo($qb, $actorId);
$qb->limitToAttributedTo($actorId, true);
$qb->execute();
}
@ -707,45 +706,14 @@ class StreamRequest extends StreamRequestBuilder {
}
$expr = $qb->expr();
$pf = $this->defaultSelectAlias . '.';
$pf = $qb->getDefaultSelectAlias() . '.';
$on = $expr->andX();
$on->add($this->exprLimitToDBFieldInt($qb, 'accepted', 1, 'fs'));
$on->add(
$this->exprLimitToDBField($qb, 'actor_id_prim', $this->prim($actor->getId()), true, true, 'fs')
);
$on->add($qb->exprLimitToDBFieldInt('accepted', 1, 'fs'));
$on->add($qb->exprLimitToDBField('actor_id_prim', $qb->prim($actor->getId()), true, true, 'fs'));
$on->add($expr->eq($pf . 'attributed_to_prim', 'fs.object_id_prim'));
$qb->leftJoin($this->defaultSelectAlias, CoreRequestBuilder::TABLE_FOLLOWS, 'fs', $on);
}
/**
* @param IQueryBuilder $qb
*
* @deprecated
*/
private function filterDuplicate(IQueryBuilder $qb) {
$actor = $this->viewer;
if ($actor === null) {
return;
}
// NEEDED ? use the follow 'f' ?
$this->leftJoinFollowStatus($qb, $actor);
$expr = $qb->expr();
$filter = $expr->orX();
$filter->add($this->exprLimitToDBFieldInt($qb, 'hidden_on_timeline', 0, 's'));
$follower = $expr->andX();
$follower->add(
$this->exprLimitToDBField($qb, 'attributed_to_prim', $this->prim($actor->getId()), false)
);
$follower->add($expr->isNull('fs.id_prim'));
$filter->add($follower);
$qb->andWhere($filter);
$qb->leftJoin($qb->getDefaultSelectAlias(), CoreRequestBuilder::TABLE_FOLLOWS, 'fs', $on);
}
}

Wyświetl plik

@ -317,6 +317,7 @@ class StreamRequestBuilder extends CoreRequestBuilder {
* @param string $recipient
* @param bool $asAuthor
* @param array $type
* @deprecated
*/
protected function limitToRecipient(
IQueryBuilder &$qb, string $recipient, bool $asAuthor = false, array $type = []

Wyświetl plik

@ -1,39 +0,0 @@
<?php
/**
* 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\Exceptions;
use Exception;
class DateTimeException extends Exception {
}

Wyświetl plik

@ -344,7 +344,7 @@ class Version0002Date20190916000001 extends SimpleMigrationStep {
$limit = 1000;
while (true) {
$qb = $this->connection->getQueryBuilder();
$qb->select('id_prim', 'to', 'to_array', 'cc', 'bcc')
$qb->select('id_prim', 'to', 'to_array', 'cc', 'bcc', 'attributed_to')
->from('social_a2_stream')
->setMaxResults(1000)
->setFirstResult($start);
@ -367,7 +367,8 @@ class Version0002Date20190916000001 extends SimpleMigrationStep {
private function insertStreamDest($data) {
$recipients = [];
$recipients['to'] = array_merge(json_decode($data['to_array'], true), [$data['to']]);
$recipients['to'] =
array_merge(json_decode($data['to_array'], true), [$data['to']], [$data['attributed_to']]);
$recipients['cc'] = array_merge(json_decode($data['cc'], true), json_decode($data['bcc'], true));
$streamId = $data['id_prim'];

Wyświetl plik

@ -31,10 +31,10 @@ declare(strict_types=1);
namespace OCA\Social\Service;
use daita\MySmallPhpTools\Exceptions\DateTimeException;
use daita\MySmallPhpTools\Traits\TArrayTools;
use OCA\Social\Db\HashtagsRequest;
use OCA\Social\Db\StreamRequest;
use OCA\Social\Exceptions\DateTimeException;
use OCA\Social\Exceptions\HashtagDoesNotExistException;
use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\SocialAppConfigException;

Wyświetl plik

@ -30,6 +30,7 @@ declare(strict_types=1);
namespace OCA\Social\Service;
use daita\MySmallPhpTools\Exceptions\DateTimeException;
use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
use daita\MySmallPhpTools\Model\Request;
use daita\MySmallPhpTools\Traits\TArrayTools;
@ -40,7 +41,6 @@ use OC;
use OCA\Social\AppInfo\Application;
use OCA\Social\Db\ActorsRequest;
use OCA\Social\Exceptions\ActorDoesNotExistException;
use OCA\Social\Exceptions\DateTimeException;
use OCA\Social\Exceptions\InvalidOriginException;
use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Exceptions\ItemUnknownException;