diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2019-09-29 13:39:25 +0200 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2019-09-29 13:44:06 +0200 |
commit | 7f02c662f66263520dba53fc8c81012608dd1405 (patch) | |
tree | 09d167805b8d459242083628b80fcfbd4a240f6a /lib | |
parent | ea2709ac91a7fdc2df0a1356a6fb20a5024502cf (diff) |
migration to ExtendedQueryBuilder
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Db/CoreRequestBuilder.php | 14 | ||||
-rw-r--r-- | lib/Db/SocialCoreQueryBuilder.php | 86 | ||||
-rw-r--r-- | lib/Db/SocialCrossQueryBuilder.php | 174 | ||||
-rw-r--r-- | lib/Db/SocialFiltersQueryBuilder.php | 69 | ||||
-rw-r--r-- | lib/Db/SocialLimitsQueryBuilder.php | 338 | ||||
-rw-r--r-- | lib/Db/SocialQueryBuilder.php | 276 | ||||
-rw-r--r-- | lib/Db/StreamRequest.php | 74 | ||||
-rw-r--r-- | lib/Db/StreamRequestBuilder.php | 54 | ||||
-rw-r--r-- | lib/Migration/Version0002Date20190916000001.php | 15 | ||||
-rw-r--r-- | lib/Migration/Version0002Date20190916000002.php | 8 |
10 files changed, 747 insertions, 361 deletions
diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 7a437ce5..16a1c32a 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -90,6 +90,7 @@ class CoreRequestBuilder { self::TABLE_STREAM_ACTIONS ]; + /** @var ILogger */ protected $logger; /** @var IDBConnection */ @@ -137,6 +138,10 @@ class CoreRequestBuilder { $this->logger ); + if ($this->viewer !== null) { + $qb->setViewer($this->viewer); + } + return $qb; } @@ -161,6 +166,7 @@ class CoreRequestBuilder { * @param string $id * * @return string + * @deprecated */ public function prim(string $id): string { if ($id === '') { @@ -184,7 +190,7 @@ class CoreRequestBuilder { /** * Limit the request to the Id - * + * @deprecated * @param IQueryBuilder $qb * @param int $id */ @@ -195,6 +201,7 @@ class CoreRequestBuilder { /** * Limit the request to the Id (string) + * @deprecated * * @param IQueryBuilder $qb * @param string $id @@ -206,6 +213,7 @@ class CoreRequestBuilder { /** * Limit the request to the UserId + * @deprecated * * @param IQueryBuilder $qb * @param string $userId @@ -533,6 +541,7 @@ class CoreRequestBuilder { * @param int $limit * * @throws DateTimeException + * @deprecated */ protected function limitPaginate(IQueryBuilder &$qb, int $since = 0, int $limit = 5) { try { @@ -763,6 +772,7 @@ class CoreRequestBuilder { /** + * @deprecated * @param IQueryBuilder $qb * @param string $alias */ @@ -958,6 +968,8 @@ class CoreRequestBuilder { /** * @param IQueryBuilder $qb + * + * @deprecated */ protected function leftJoinStreamAction(IQueryBuilder &$qb) { if ($qb->getType() !== QueryBuilder::SELECT || $this->viewer === null) { diff --git a/lib/Db/SocialCoreQueryBuilder.php b/lib/Db/SocialCoreQueryBuilder.php new file mode 100644 index 00000000..917a2b1c --- /dev/null +++ b/lib/Db/SocialCoreQueryBuilder.php @@ -0,0 +1,86 @@ +<?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\Db; + + +use daita\MySmallPhpTools\Db\ExtendedQueryBuilder; +use OCA\Social\Model\ActivityPub\Actor\Person; + + +/** + * Class SocialCoreQueryBuilder + * + * @package OCA\Social\Db + */ +class SocialCoreQueryBuilder extends ExtendedQueryBuilder { + + + /** @var Person */ + private $viewer = null; + + + /** + * @return bool + */ + public function hasViewer(): bool { + return ($this->viewer !== null); + } + + /** + * @param Person $viewer + */ + public function setViewer(Person $viewer): void { + $this->viewer = $viewer; + } + + /** + * @return Person + */ + public function getViewer(): Person { + return $this->viewer; + } + + + /** + * @param string $id + * + * @return string + */ + public function prim(string $id): string { + if ($id === '') { + return ''; + } + + return hash('sha512', $id); + } + +} + diff --git a/lib/Db/SocialCrossQueryBuilder.php b/lib/Db/SocialCrossQueryBuilder.php new file mode 100644 index 00000000..525c3778 --- /dev/null +++ b/lib/Db/SocialCrossQueryBuilder.php @@ -0,0 +1,174 @@ +<?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\Db; + + +use Doctrine\DBAL\Query\QueryBuilder; + + +/** + * Class SocialCrossQueryBuilder + * + * @package OCA\Social\Db + */ +class SocialCrossQueryBuilder extends SocialCoreQueryBuilder { + + + /** + * @param string $aliasDest + * @param string $aliasFollowing + */ + public function selectDestFollowing(string $aliasDest = 'sd', string $aliasFollowing = 'f') { + if ($this->getType() !== QueryBuilder::SELECT) { + return; + } + + if ($aliasDest !== '') { + $this->from(CoreRequestBuilder::TABLE_STREAM_DEST, $aliasDest); + } + if ($aliasFollowing !== '') { + $this->from(CoreRequestBuilder::TABLE_FOLLOWS, $aliasFollowing); + } + } + + + /** + * @param string $alias + */ + public function selectCacheActors(string $alias = 'ca') { + if ($this->getType() !== QueryBuilder::SELECT) { + return; + } + + $pf = (($alias === '') ? $this->getDefaultSelectAlias() : $alias); + $this->from(CoreRequestBuilder::TABLE_CACHE_ACTORS, $pf); + $this->selectAlias($pf . '.id', 'cacheactor_id') + ->selectAlias($pf . '.type', 'cacheactor_type') + ->selectAlias($pf . '.account', 'cacheactor_account') + ->selectAlias($pf . '.following', 'cacheactor_following') + ->selectAlias($pf . '.followers', 'cacheactor_followers') + ->selectAlias($pf . '.inbox', 'cacheactor_inbox') + ->selectAlias($pf . '.shared_inbox', 'cacheactor_shared_inbox') + ->selectAlias($pf . '.outbox', 'cacheactor_outbox') + ->selectAlias($pf . '.featured', 'cacheactor_featured') + ->selectAlias($pf . '.url', 'cacheactor_url') + ->selectAlias($pf . '.preferred_username', 'cacheactor_preferred_username') + ->selectAlias($pf . '.name', 'cacheactor_name') + ->selectAlias($pf . '.summary', 'cacheactor_summary') + ->selectAlias($pf . '.public_key', 'cacheactor_public_key') + ->selectAlias($pf . '.source', 'cacheactor_source') + ->selectAlias($pf . '.creation', 'cacheactor_creation') + ->selectAlias($pf . '.local', 'cacheactor_local'); + } + + + /** + * @param string $alias + */ + public function leftJoinFollowStatus(string $alias = 'fs') { + if ($this->getType() !== QueryBuilder::SELECT || !$this->hasViewer()) { + return; + } + + $expr = $this->expr(); + $actor = $this->getViewer(); + $pf = $this->getDefaultSelectAlias() . '.'; + + $idPrim = $this->prim($actor->getId()); + + $on = $expr->andX(); + $on->add($this->exprLimitToDBFieldInt('accepted', 1, $alias)); + $on->add($this->exprLimitToDBField('actor_id_prim', $idPrim, true, true, $alias)); + $on->add($expr->eq($pf . 'attributed_to_prim', $alias . '.object_id_prim')); + + $this->leftJoin($this->getDefaultSelectAlias(), CoreRequestBuilder::TABLE_FOLLOWS, $alias, $on); + } + + + /** + * @param string $alias + */ + public function leftJoinStreamAction(string $alias = 'sa') { + if ($this->getType() !== QueryBuilder::SELECT || !$this->hasViewer()) { + return; + } + + $pf = $this->getDefaultSelectAlias(); + $expr = $this->expr(); + + $this->selectAlias($alias . '.id', 'streamaction_id') + ->selectAlias($alias . '.actor_id', 'streamaction_actor_id') + ->selectAlias($alias . '.stream_id', 'streamaction_stream_id') + ->selectAlias($alias . '.values', 'streamaction_values'); + + $orX = $expr->orX(); + $orX->add($expr->eq($alias . '.stream_id_prim', $pf . '.id_prim')); + $orX->add($expr->eq($alias . '.stream_id_prim', $pf . '.object_id_prim')); + + $on = $expr->andX(); + $viewer = $this->getViewer(); + $idPrim = $this->prim($viewer->getId()); + + $on->add($expr->eq($alias . '.actor_id_prim', $this->createNamedParameter($idPrim))); + $on->add($orX); + + $this->leftJoin($this->getDefaultSelectAlias(), CoreRequestBuilder::TABLE_STREAM_ACTIONS, 'sa', $on); + } + + + /** + * @param string $actorId + * @param string $type + * @param string $field + * @param string $aliasDest + * @param string $aliasFollowing + * @param string $alias + */ + public function innerJoinDestFollowing( + string $actorId, string $type, string $field = 'id_prim', string $aliasDest = 'sd', + string $aliasFollowing = 'f', string $alias = '' + ) { + $expr = $this->expr(); + $andX = $expr->andX(); + $pf = (($alias === '') ? $this->getdefaultSelectAlias() : $alias) . '.'; + + $idPrim = $this->prim($actorId); + $andX->add($this->exprLimitToDBField('actor_id_prim', $idPrim, true, true, $aliasFollowing)); + $andX->add($this->exprLimitToDBFieldInt('accepted', 1, $aliasFollowing)); + $andX->add($expr->eq($aliasFollowing . '.follow_id_prim', $aliasDest . '.actor_id')); + $andX->add($expr->eq($aliasDest . '.stream_id', $pf . $field)); + $andX->add($expr->eq($aliasDest . '.type', $this->createNamedParameter($type))); + + $this->andWhere($andX); + } + +} + diff --git a/lib/Db/SocialFiltersQueryBuilder.php b/lib/Db/SocialFiltersQueryBuilder.php new file mode 100644 index 00000000..e0d2e7c2 --- /dev/null +++ b/lib/Db/SocialFiltersQueryBuilder.php @@ -0,0 +1,69 @@ +<?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\Db; + + +use OCP\DB\QueryBuilder\IQueryBuilder; + + +/** + * Class SocialFiltersQueryBuilder + * + * @package OCA\Social\Db + */ +class SocialFiltersQueryBuilder extends SocialLimitsQueryBuilder { + + + /** + * @param IQueryBuilder $qb + */ + public function filterDuplicate() { + if (!$this->hasViewer()) { + return; + } + + $viewer = $this->getViewer(); + $this->leftJoinFollowStatus('fs'); + + $expr = $this->expr(); + $filter = $expr->orX(); + $filter->add($this->exprLimitToDBFieldInt('hidden_on_timeline', 0, 's')); + + $follower = $expr->andX(); + $follower->add($this->exprLimitToDBField('attributed_to_prim', $this->prim($viewer->getId()), false)); + $follower->add($expr->isNull('fs.id_prim')); + $filter->add($follower); + + $this->andWhere($filter); + } + +} + diff --git a/lib/Db/SocialLimitsQueryBuilder.php b/lib/Db/SocialLimitsQueryBuilder.php new file mode 100644 index 00000000..afdee38f --- /dev/null +++ b/lib/Db/SocialLimitsQueryBuilder.php @@ -0,0 +1,338 @@ +<?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\Db; + + +use DateInterval; +use DateTime; +use Exception; +use OCA\Social\Exceptions\DateTimeException; +use OCA\Social\Model\ActivityPub\ACore; + + +/** + * Class SocialLimitsQueryBuilder + * + * @package OCA\Social\Db + */ +class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder { + + /** + * Limit the request to the Type + * + * @param string $type + * + * @return SocialQueryBuilder + */ + public function limitToType(string $type): self { + $this->limitToDBField('type', $type, false); + + return $this; + } + + + /** + * Limit the request to the ActivityId + * + * @param string $activityId + */ + public function limitToActivityId(string $activityId) { + $this->limitToDBField('activity_id', $activityId, false); + } + + + /** + * Limit the request to the Id (string) + * + * @param string $id + */ + public function limitToInReplyTo(string $id) { + $this->limitToDBField('in_reply_to', $id, false); + } + + + /** + * Limit the request to the sub-type + * + * @param string $subType + */ + public function limitToSubType(string $subType) { + $this->limitToDBField('subtype', $subType); + } + + + /** + * @param string $type + */ + public function filterType(string $type) { + $this->filterDBField('type', $type); + } + + + /** + * Limit the request to the Preferred Username + * + * @param string $username + */ + public function limitToPreferredUsername(string $username) { + $this->limitToDBField('preferred_username', $username, false); + } + + + /** + * Limit the request to the ActorId + */ + public function limitToPublic() { + $this->limitToDBFieldInt('public', 1); + } + + + /** + * Limit the request to the ActorId + */ + public function limitToIdPrim(string $id) { + $this->limitToDBField('id_prim', $id); + } + + + /** + * Limit the request to the token + * + * @param string $token + */ + public function limitToToken(string $token) { + $this->limitToDBField('token', $token); + } + + /** + * Limit the results to a given number + * + * @param int $limit + */ + public function limitResults(int $limit) { + $this->setMaxResults($limit); + } + + + /** + * Limit the request to the ActorId + * + * @param string $hashtag + */ + public function limitToHashtag(string $hashtag) { + $this->limitToDBField('hashtag', $hashtag, false); + } + + + /** + * Limit the request to the ActorId + * + * @param string $actorId + * @param string $alias + */ + public function limitToActorId(string $actorId, string $alias = '') { + $this->limitToDBField('actor_id', $actorId, false, $alias); + } + + + /** + * Limit the request to the FollowId + * + * @param string $followId + */ + public function limitToFollowId(string $followId) { + $this->limitToDBField('follow_id', $followId, false); + } + + + /** + * Limit the request to the FollowId + * + * @param bool $accepted + * @param string $alias + */ + public function limitToAccepted(bool $accepted, string $alias = '') { + $this->limitToDBField('accepted', ($accepted) ? '1' : '0', true, $alias); + } + + + /** + * Limit the request to the ServiceId + * + * @param string $objectId + */ + public function limitToObjectId(string $objectId) { + $this->limitToDBField('object_id', $objectId, false); + } + + + /** + * Limit the request to the account + * + * @param string $account + */ + public function limitToAccount(string $account) { + $this->limitToDBField('account', $account, false); + } + + + /** + * Limit the request to the creation + * + * @param int $delay + * + * @throws Exception + */ + public function limitToCaching(int $delay = 0) { + $date = new DateTime('now'); + $date->sub(new DateInterval('PT' . $delay . 'M')); + + $this->limitToDBFieldDateTime('caching', $date, true); + } + + + /** + * Limit the request to the url + * + * @param string $url + */ + public function limitToUrl(string $url) { + $this->limitToDBField('url', $url); + } + + + /** + * Limit the request to the url + * + * @param string $actorId + */ + public function limitToAttributedTo(string $actorId) { + $this->limitToDBField('attributed_to', $actorId, false); + } + + + /** + * Limit the request to the status + * + * @param int $status + */ + public function limitToStatus(int $status) { + $this->limitToDBFieldInt('status', $status); + } + + + /** + * Limit the request to the instance + * + * @param string $address + */ + public function limitToAddress(string $address) { + $this->limitToDBField('address', $address); + } + + + /** + * Limit the request to the instance + * + * @param bool $local + */ + public function limitToLocal(bool $local) { + $this->limitToDBField('local', ($local) ? '1' : '0'); + } + + + /** + * Limit the request to the parent_id + * + * @param string $parentId + */ + public function limitToParentId(string $parentId) { + $this->limitToDBField('parent_id', $parentId); + } + + + /** + * @param int $since + * @param int $limit + * + * @throws DateTimeException + */ + public function limitPaginate(int $since = 0, int $limit = 5) { + try { + if ($since > 0) { + $dTime = new DateTime(); + $dTime->setTimestamp($since); + $this->limitToDBFieldDateTime('published_time', $dTime); + } + } catch (Exception $e) { + throw new DateTimeException(); + } + + $this->setMaxResults($limit); + $pf = $this->getDefaultSelectAlias(); + $this->orderBy($pf . '.published_time', 'desc'); + } + + + /** + * @param string $actorId + * @param string $type + * @param string $subType + * @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); + + if ($subType !== '') { + $this->limitToDBField('subtype', $subType, true, $alias); + } + } + + + /** + * @param string $aliasDest + * @param string $aliasFollowing + */ + public function limitToViewer(string $aliasDest = 'sd', string $aliasFollowing = 'f') { + if (!$this->hasViewer()) { + $this->selectDestFollowing($aliasDest); + $this->limitToDest(ACore::CONTEXT_PUBLIC, 'recipient', '', $aliasDest); + + return; + } + + $actor = $this->getViewer(); + $this->selectDestFollowing($aliasDest, $aliasFollowing); + $this->innerJoinDestFollowing($actor->getId(), 'recipient', 'id_prim', $aliasDest, $aliasFollowing); + } +} + diff --git a/lib/Db/SocialQueryBuilder.php b/lib/Db/SocialQueryBuilder.php index b1e01a8a..872ed14c 100644 --- a/lib/Db/SocialQueryBuilder.php +++ b/lib/Db/SocialQueryBuilder.php @@ -31,313 +31,59 @@ declare(strict_types=1); namespace OCA\Social\Db; -use daita\MySmallPhpTools\Db\ExtendedQueryBuilder; -use DateInterval; -use DateTime; -use Exception; -use OCA\Social\Model\ActivityPub\Actor\Person; - - /** * Class SocialQueryBuilder * - * @package OCA\Push\Db + * @package OCA\Social\Db */ -class SocialQueryBuilder extends ExtendedQueryBuilder { - - - /** @var Person */ - private $viewer = null; - - - /** - * @return bool - */ - public function hasViewer(): bool { - return ($this->viewer !== null); - } - - /** - * @param Person $viewer - */ - public function setViewer(Person $viewer): void { - $this->viewer = $viewer; - } - - /** - * @return Person - */ - public function getViewer(): Person { - return $this->viewer; - } +class SocialQueryBuilder extends SocialFiltersQueryBuilder { /** * @param string $id + * @param string $field */ - public function generatePrimaryKey(string $id) { - $this->setValue('id_prim', $this->createNamedParameter(hash('sha512', $id))); - } - - - /** - * Limit the request to the Type - * - * @param string $type - * - * @return SocialQueryBuilder - */ - public function limitToType(string $type): self { - $this->limitToDBField('type', $type, false); - - return $this; - } - - - /** - * Limit the request to the ActivityId - * - * @param string $activityId - */ - protected function limitToActivityId(string $activityId) { - $this->limitToDBField('activity_id', $activityId, false); - } - + public function generatePrimaryKey(string $id, string $field = 'id_prim') { + if ($id === '') { + return; + } - /** - * Limit the request to the Id (string) - * - * @param string $id - */ - protected function limitToInReplyTo(string $id) { - $this->limitToDBField('in_reply_to', $id, false); + $this->setValue($field, $this->createNamedParameter($this->prim($id))); } /** - * Limit the request to the sub-type - * - * @param string $subType - */ - protected function limitToSubType(string $subType) { - $this->limitToDBField('subtype', $subType); - } - - - /** - * @param string $type - */ - protected function filterType(string $type) { - $this->filterDBField('type', $type); - } - - - /** - * Limit the request to the Preferred Username - * - * @param string $username - */ - protected function limitToPreferredUsername(string $username) { - $this->limitToDBField('preferred_username', $username, false); - } - - /** * search using username * * @param string $username */ - protected function searchInPreferredUsername(string $username) { + public function searchInPreferredUsername(string $username) { $dbConn = $this->getConnection(); $this->searchInDBField('preferred_username', $dbConn->escapeLikeParameter($username) . '%'); } - - /** - * Limit the request to the ActorId - */ - protected function limitToPublic() { - $this->limitToDBFieldInt('public', 1); - } - - - /** - * Limit the request to the token - * - * @param string $token - */ - protected function limitToToken(string $token) { - $this->limitToDBField('token', $token); - } - - /** - * Limit the results to a given number - * - * @param int $limit - */ - protected function limitResults(int $limit) { - $this->setMaxResults($limit); - } - - - /** - * Limit the request to the ActorId - * - * @param string $hashtag - */ - protected function limitToHashtag(string $hashtag) { - $this->limitToDBField('hashtag', $hashtag, false); - } - - /** * Limit the request to the ActorId * * @param string $hashtag * @param bool $all */ - protected function searchInHashtag(string $hashtag, bool $all = false) { + public function searchInHashtag(string $hashtag, bool $all = false) { $dbConn = $this->getConnection(); $this->searchInDBField('hashtag', (($all) ? '%' : '') . $dbConn->escapeLikeParameter($hashtag) . '%'); } /** - * Limit the request to the ActorId - * - * @param string $actorId - * @param string $alias - */ - protected function limitToActorId(string $actorId, string $alias = '') { - $this->limitToDBField('actor_id', $actorId, false, $alias); - } - - - /** - * Limit the request to the FollowId - * - * @param string $followId - */ - protected function limitToFollowId(string $followId) { - $this->limitToDBField('follow_id', $followId, false); - } - - - /** - * Limit the request to the FollowId - * - * @param bool $accepted - * @param string $alias - */ - protected function limitToAccepted(bool $accepted, string $alias = '') { - $this->limitToDBField('accepted', ($accepted) ? '1' : '0', true, $alias); - } - - - /** - * Limit the request to the ServiceId - * - * @param string $objectId - */ - protected function limitToObjectId(string $objectId) { - $this->limitToDBField('object_id', $objectId, false); - } - - - /** * Limit the request to the account * * @param string $account */ - protected function limitToAccount(string $account) { - $this->limitToDBField('account', $account, false); - } - - - /** - * Limit the request to the account - * - * @param string $account |