summaryrefslogtreecommitdiffstats
path: root/lib/Db
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-10-03 11:22:55 -0100
committerGitHub <noreply@github.com>2019-10-03 11:22:55 -0100
commitd786434128de467b83615594bcd94b1571e13cfd (patch)
tree4ad39f85d0c25ef3eb65a6a7fbe64bb5a79756c3 /lib/Db
parent55abe1ab215b2a914b5b3500c5a3f47ab4bd2e64 (diff)
parent9d38a7fa70eae0f16a3c5d832d1b5486ecb7b94c (diff)
Merge branch 'master' into feature/noid/returns-viewer-link-on-actor
Diffstat (limited to 'lib/Db')
-rw-r--r--lib/Db/CacheActorsRequestBuilder.php4
-rw-r--r--lib/Db/CoreRequestBuilder.php2
-rw-r--r--lib/Db/FollowsRequest.php10
-rw-r--r--lib/Db/FollowsRequestBuilder.php6
-rw-r--r--lib/Db/SocialCrossQueryBuilder.php42
-rw-r--r--lib/Db/SocialLimitsQueryBuilder.php4
-rw-r--r--lib/Db/StreamDestRequest.php2
-rw-r--r--lib/Db/StreamDestRequestBuilder.php8
-rw-r--r--lib/Db/StreamRequest.php55
-rw-r--r--lib/Db/StreamTagsRequest.php78
-rw-r--r--lib/Db/StreamTagsRequestBuilder.php105
11 files changed, 265 insertions, 51 deletions
diff --git a/lib/Db/CacheActorsRequestBuilder.php b/lib/Db/CacheActorsRequestBuilder.php
index 49518edc..f5e2956d 100644
--- a/lib/Db/CacheActorsRequestBuilder.php
+++ b/lib/Db/CacheActorsRequestBuilder.php
@@ -160,7 +160,7 @@ class CacheActorsRequestBuilder extends CoreRequestBuilder {
return $actor;
}
-
+
/**
* @param SocialQueryBuilder $qb
* @param Person $actor
@@ -179,6 +179,6 @@ class CacheActorsRequestBuilder extends CoreRequestBuilder {
$actor->setViewerLink($link);
}
-
+
}
diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php
index 4ddd6ece..dc347c64 100644
--- a/lib/Db/CoreRequestBuilder.php
+++ b/lib/Db/CoreRequestBuilder.php
@@ -65,6 +65,7 @@ class CoreRequestBuilder {
const TABLE_ACTORS = 'social_a2_actors';
const TABLE_STREAM = 'social_a2_stream';
const TABLE_STREAM_DEST = 'social_a2_stream_dest';
+ const TABLE_STREAM_TAGS = 'social_a2_stream_tags';
const TABLE_STREAM_QUEUE = 'social_a2_stream_queue';
const TABLE_STREAM_ACTIONS = 'social_a2_stream_action';
@@ -87,6 +88,7 @@ class CoreRequestBuilder {
self::TABLE_CACHE_DOCUMENTS,
self::TABLE_STREAM_QUEUE,
self::TABLE_STREAM_DEST,
+ self::TABLE_STREAM_TAGS,
self::TABLE_STREAM_ACTIONS
];
diff --git a/lib/Db/FollowsRequest.php b/lib/Db/FollowsRequest.php
index cf2b19d3..ec46401f 100644
--- a/lib/Db/FollowsRequest.php
+++ b/lib/Db/FollowsRequest.php
@@ -169,8 +169,9 @@ class FollowsRequest extends FollowsRequestBuilder {
*/
public function countFollowers(string $actorId): int {
$qb = $this->countFollowsSelectSql();
- $this->limitToObjectId($qb, $actorId);
- $this->limitToAccepted($qb, true);
+ $qb->limitToObjectId($actorId);
+ $qb->limitToType(Follow::TYPE);
+ $qb->limitToAccepted(true);
$cursor = $qb->execute();
$data = $cursor->fetch();
@@ -187,8 +188,9 @@ class FollowsRequest extends FollowsRequestBuilder {
*/
public function countFollowing(string $actorId): int {
$qb = $this->countFollowsSelectSql();
- $this->limitToActorId($qb, $actorId);
- $this->limitToAccepted($qb, true);
+ $qb->limitToActorId($actorId);
+ $qb->limitToType(Follow::TYPE);
+ $qb->limitToAccepted(true);
$cursor = $qb->execute();
$data = $cursor->fetch();
diff --git a/lib/Db/FollowsRequestBuilder.php b/lib/Db/FollowsRequestBuilder.php
index a41e7114..550dd278 100644
--- a/lib/Db/FollowsRequestBuilder.php
+++ b/lib/Db/FollowsRequestBuilder.php
@@ -97,10 +97,10 @@ class FollowsRequestBuilder extends CoreRequestBuilder {
/**
* Base of the Sql Select request for Shares
*
- * @return IQueryBuilder
+ * @return SocialQueryBuilder
*/
- protected function countFollowsSelectSql(): IQueryBuilder {
- $qb = $this->dbConnection->getQueryBuilder();
+ protected function countFollowsSelectSql(): SocialQueryBuilder {
+ $qb = $this->getQueryBuilder();
$qb->selectAlias($qb->createFunction('COUNT(*)'), 'count')
->from(self::TABLE_FOLLOWS, 'f');
diff --git a/lib/Db/SocialCrossQueryBuilder.php b/lib/Db/SocialCrossQueryBuilder.php
index bfd99de7..4cd50c5d 100644
--- a/lib/Db/SocialCrossQueryBuilder.php
+++ b/lib/Db/SocialCrossQueryBuilder.php
@@ -66,7 +66,24 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
* @param string $alias
* @param string $link
*/
- public function innerJoinCacheActors(string $alias = 'ca', string $link = '') {
+ public function linkToStreamTags(string $alias = 'st', string $link = '') {
+ if ($this->getType() !== QueryBuilder::SELECT) {
+ return;
+ }
+
+ $this->from(CoreRequestBuilder::TABLE_STREAM_TAGS, $alias);
+ if ($link !== '') {
+ $expr = $this->expr();
+ $this->andWhere($expr->eq($alias . '.stream_id', $link));
+ }
+ }
+
+
+ /**
+ * @param string $alias
+ * @param string $link
+ */
+ public function linkToCacheActors(string $alias = 'ca', string $link = '') {
if ($this->getType() !== QueryBuilder::SELECT) {
return;
}
@@ -173,15 +190,14 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
/**
* @param string $type
- * @param string $subType
* @param string $field
* @param string $aliasDest
* @param string $alias
*/
- public function innerJoinDest(
+ public function innerJoinSteamDest(
string $type, string $field = 'id_prim', string $aliasDest = 'sd', string $alias = ''
) {
- $this->andWhere($this->exprInnerJoinDest($type, $field, $aliasDest, $alias));
+ $this->andWhere($this->exprInnerJoinStreamDest($type, $field, $aliasDest, $alias));
}
@@ -194,7 +210,7 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
*
* @return ICompositeExpression
*/
- public function exprInnerJoinDest(
+ public function exprInnerJoinStreamDest(
string $type, string $field = 'id_prim', string $aliasDest = 'sd', string $alias = ''
): ICompositeExpression {
$expr = $this->expr();
@@ -207,12 +223,22 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
}
- public function innerJoinDestFollowing(
+ /**
+ * @param string $actorId
+ * @param string $type
+ * @param string $field
+ * @param string $aliasDest
+ * @param string $aliasFollowing
+ * @param string $alias
+ */
+ public function innerJoinStreamDestFollowing(
string $actorId, string $type, string $field = 'id_prim', string $aliasDest = 'sd',
string $aliasFollowing = 'f', string $alias = ''
) {
$this->andWhere(
- $this->exprInnerJoinDestFollowing($actorId, $type, $field, $aliasDest, $aliasFollowing, $alias)
+ $this->exprInnerJoinStreamDestFollowing(
+ $actorId, $type, $field, $aliasDest, $aliasFollowing, $alias
+ )
);
}
@@ -227,7 +253,7 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
*
* @return ICompositeExpression
*/
- public function exprInnerJoinDestFollowing(
+ public function exprInnerJoinStreamDestFollowing(
string $actorId, string $type, string $field = 'id_prim', string $aliasDest = 'sd',
string $aliasFollowing = 'f', string $alias = ''
): ICompositeExpression {
diff --git a/lib/Db/SocialLimitsQueryBuilder.php b/lib/Db/SocialLimitsQueryBuilder.php
index f4c21bb5..e3cb83ae 100644
--- a/lib/Db/SocialLimitsQueryBuilder.php
+++ b/lib/Db/SocialLimitsQueryBuilder.php
@@ -365,7 +365,7 @@ class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder {
) {
if (!$this->hasViewer()) {
$this->selectDestFollowing($aliasDest);
- $this->innerJoinDest('recipient', 'id_prim', 'sd', 's');
+ $this->innerJoinSteamDest('recipient', 'id_prim', 'sd', 's');
$this->limitToDest(ACore::CONTEXT_PUBLIC, 'recipient', '', $aliasDest);
return;
@@ -376,7 +376,7 @@ class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder {
$orX = $expr->orX();
$actor = $this->getViewer();
- $following = $this->exprInnerJoinDestFollowing(
+ $following = $this->exprInnerJoinStreamDestFollowing(
$actor->getId(), 'recipient', 'id_prim', $aliasDest, $aliasFollowing
);
$orX->add($following);
diff --git a/lib/Db/StreamDestRequest.php b/lib/Db/StreamDestRequest.php
index 8ea6908d..78194f0d 100644
--- a/lib/Db/StreamDestRequest.php
+++ b/lib/Db/StreamDestRequest.php
@@ -87,7 +87,7 @@ class StreamDestRequest extends StreamDestRequestBuilder {
$qb->execute();
} catch (UniqueConstraintViolationException $e) {
\OC::$server->getLogger()
- ->log(3, 'Social - Duplicate recipient on Stream ' . json_encode($stream));
+ ->log(1, 'Social - Duplicate recipient on Stream ' . json_encode($stream));
}
}
}
diff --git a/lib/Db/StreamDestRequestBuilder.php b/lib/Db/StreamDestRequestBuilder.php
index 9bb60738..986e0215 100644
--- a/lib/Db/StreamDestRequestBuilder.php
+++ b/lib/Db/StreamDestRequestBuilder.php
@@ -64,7 +64,7 @@ class StreamDestRequestBuilder extends CoreRequestBuilder {
* @return IQueryBuilder
*/
protected function getStreamDestUpdateSql(): IQueryBuilder {
- $qb = $this->dbConnection->getQueryBuilder();
+ $qb = $this->getQueryBuilder();
$qb->update(self::TABLE_STREAM_DEST);
return $qb;
@@ -77,7 +77,7 @@ class StreamDestRequestBuilder extends CoreRequestBuilder {
* @return IQueryBuilder
*/
protected function getStreamDestSelectSql(): IQueryBuilder {
- $qb = $this->dbConnection->getQueryBuilder();
+ $qb = $this->getQueryBuilder();
/** @noinspection PhpMethodParametersCountMismatchInspection */
$qb->select('sd.actor_id', 'sd.stream_id', 'sd.type')
@@ -95,7 +95,7 @@ class StreamDestRequestBuilder extends CoreRequestBuilder {
* @return IQueryBuilder
*/
protected function getStreamDestDeleteSql(): IQueryBuilder {
- $qb = $this->dbConnection->getQueryBuilder();
+ $qb = $this->getQueryBuilder();
$qb->delete(self::TABLE_STREAM_DEST);
return $qb;
@@ -108,7 +108,7 @@ class StreamDestRequestBuilder extends CoreRequestBuilder {
* @return IQueryBuilder
*/
protected function countStreamDestSelectSql(): IQueryBuilder {
- $qb = $this->dbConnection->getQueryBuilder();
+ $qb = $this->getQueryBuilder();
$qb->selectAlias($qb->createFunction('COUNT(*)'), 'count')
->from(self::TABLE_STREAM_DEST, 'sd');
diff --git a/lib/Db/StreamRequest.php b/lib/Db/StreamRequest.php
index a4d1ab0f..225d060e 100644
--- a/lib/Db/StreamRequest.php
+++ b/lib/Db/StreamRequest.php
@@ -62,6 +62,9 @@ class StreamRequest extends StreamRequestBuilder {
/** @var StreamDestRequest */
private $streamDestRequest;
+ /** @var StreamTagsRequest */
+ private $streamTagsRequest;
+
/**
* StreamRequest constructor.
@@ -74,11 +77,12 @@ class StreamRequest extends StreamRequestBuilder {
*/
public function __construct(
IDBConnection $connection, ILogger $logger, StreamDestRequest $streamDestRequest,
- ConfigService $configService, MiscService $miscService
+ StreamTagsRequest $streamTagsRequest, ConfigService $configService, MiscService $miscService
) {
parent::__construct($connection, $logger, $configService, $miscService);
$this->streamDestRequest = $streamDestRequest;
+ $this->streamTagsRequest = $streamTagsRequest;
}
@@ -101,6 +105,7 @@ class StreamRequest extends StreamRequestBuilder {
$qb->execute();
$this->streamDestRequest->generateStreamDest($stream);
+ $this->streamTagsRequest->generateStreamTags($stream);
} catch (UniqueConstraintViolationException $e) {
}
}
@@ -231,7 +236,7 @@ class StreamRequest extends StreamRequestBuilder {
$expr = $qb->expr();
$qb->limitToIdPrim($qb->prim($id));
- $qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
+ $qb->linkToCacheActors('ca', 's.attributed_to_prim');
if ($asViewer) {
$qb->limitToViewer('sd', 'f', true);
@@ -271,7 +276,7 @@ class StreamRequest extends StreamRequestBuilder {
$qb->limitPaginate($since, $limit);
$expr = $qb->expr();
- $qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
+ $qb->linkToCacheActors('ca', 's.attributed_to_prim');
$qb->andWhere($expr->eq('s.attributed_to', 'ca.id_prim'));
@@ -337,7 +342,7 @@ class StreamRequest extends StreamRequestBuilder {
$qb->limitToType(Note::TYPE);
$qb->selectDestFollowing('sd', '');
- $qb->innerJoinDest('recipient', 'id_prim', 'sd', 's');
+ $qb->innerJoinSteamDest('recipient', 'id_prim', 'sd', 's');
$qb->limitToDest(ACore::CONTEXT_PUBLIC, 'recipient', '', 'sd');
$cursor = $qb->execute();
@@ -364,12 +369,11 @@ class StreamRequest extends StreamRequestBuilder {
$qb = $this->getStreamSelectSql();
$expr = $qb->expr();
- $qb->innerJoinCacheActors('ca', 'f.object_id_prim');
+ $qb->linkToCacheActors('ca', 'f.object_id_prim');
$qb->limitPaginate($since, $limit);
$qb->andWhere($qb->exprLimitToDBField('type', SocialAppNotification::TYPE, false));
$qb->limitToViewer('sd', 'f', false);
- $qb->andWhere($expr->eq('f.object_id_prim', 'ca.id_prim'));
$qb->leftJoinStreamAction('sa');
$qb->filterDuplicate();
@@ -402,7 +406,7 @@ class StreamRequest extends StreamRequestBuilder {
$qb->limitToDest($actor->getId(), 'recipient', '', 'sd');
$qb->limitToType(SocialAppNotification::TYPE);
- $qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
+ $qb->linkToCacheActors('ca', 's.attributed_to_prim');
$qb->leftJoinStreamAction();
return $this->getStreamsFromRequest($qb);
@@ -428,10 +432,10 @@ class StreamRequest extends StreamRequestBuilder {
$qb->limitToAttributedTo($actorId);
$qb->selectDestFollowing('sd', '');
- $qb->innerJoinDest('recipient', 'id_prim', 'sd', 's');
+ $qb->innerJoinSteamDest('recipient', 'id_prim', 'sd', 's');
$qb->limitToDest(ACore::CONTEXT_PUBLIC, 'recipient', '', 'sd');
- $qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
+ $qb->linkToCacheActors('ca', 's.attributed_to_prim');
$qb->leftJoinStreamAction();
return $this->getStreamsFromRequest($qb);
@@ -456,10 +460,10 @@ class StreamRequest extends StreamRequestBuilder {
$qb->filterType(SocialAppNotification::TYPE);
$qb->limitPaginate($since, $limit);
- $qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
+ $qb->linkToCacheActors('ca', 's.attributed_to_prim');
$qb->selectDestFollowing('sd', '');
- $qb->innerJoinDest('recipient', 'id_prim', 'sd', 's');
+ $qb->innerJoinSteamDest('recipient', 'id_prim', 'sd', 's');
$qb->limitToDest($actor->getId(), 'recipient', '', 'sd');
$qb->filterDest(ACore::CONTEXT_PUBLIC);
@@ -489,11 +493,11 @@ class StreamRequest extends StreamRequestBuilder {
$qb->limitToLocal($localOnly);
$qb->limitToType(Note::TYPE);
- $qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
+ $qb->linkToCacheActors('ca', 's.attributed_to_prim');
$qb->leftJoinStreamAction();
$qb->selectDestFollowing('sd', '');
- $qb->innerJoinDest('recipient', 'id_prim', 'sd', 's');
+ $qb->innerJoinSteamDest('recipient', 'id_prim', 'sd', 's');
$qb->limitToDest(ACore::CONTEXT_PUBLIC, 'recipient', 'to', 'sd');
return $this->getStreamsFromRequest($qb);
@@ -522,7 +526,7 @@ class StreamRequest extends StreamRequestBuilder {
$qb->limitPaginate($since, $limit);
$expr = $qb->expr();
- $qb->innerJoinCacheActors('ca', 's.attributed_to_prim');
+ $qb->linkToCacheActors('ca', 's.attributed_to_prim');
$qb->selectStreamActions('sa');
$qb->andWhere($expr->eq('sa.stream_id_prim', 's.id_prim'));
@@ -539,7 +543,6 @@ class StreamRequest extends StreamRequestBuilder {
* - direct message related to a tag (not yet)
* - message to followers related to a tag (not yet)
*
- * @param Person $actor
* @param string $hashtag
* @param int $since
* @param int $limit
@@ -547,23 +550,21 @@ class StreamRequest extends StreamRequestBuilder {
* @return Stream[]
* @throws DateTimeException
*/
- public function getTimelineTag(Person $actor, string $hashtag, int $since = 0, int $limit = 5
- ): array {
+ public function getTimelineTag(string $hashtag, int $since = 0, int $limit = 5): 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));
- $qb->join($this->defaultSelectAlias, CoreRequestBuilder::TABLE_FOLLOWS, 'f', $on);
+ $expr = $qb->expr();
+ $qb->linkToCacheActors('ca', 's.attributed_to_prim');
+ $qb->linkToStreamTags('st', 's.id_prim');
+ $qb->limitPaginate($since, $limit);
- $qb->andWhere($this->exprValueWithinJsonFormat($qb, 'hashtags', '' . $hashtag));
+ $qb->andWhere($qb->exprLimitToDBField('type', Note::TYPE));
+ $qb->andWhere($qb->exprLimitToDBField('hashtag', $hashtag, true, false, 'st'));
- $qb->limitPaginate($since, $limit);
-// $this->filterHiddenOnTimeline($qb);
+ $qb->limitToViewer('sd', 'f', true);
+ $qb->andWhere($expr->eq('s.attributed_to_prim', 'ca.id_prim'));
- $this->leftJoinCacheActors($qb, 'attributed_to');
- $this->leftJoinStreamAction($qb);
+ $qb->leftJoinStreamAction('sa');
return $this->getStreamsFromRequest($qb);
}
diff --git a/lib/Db/StreamTagsRequest.php b/lib/Db/StreamTagsRequest.php
new file mode 100644
index 00000000..4b80d34a
--- /dev/null
+++ b/lib/Db/StreamTagsRequest.php
@@ -0,0 +1,78 @@
+<?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\Traits\TStringTools;
+use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
+use OCA\Social\Model\ActivityPub\Stream;
+
+
+/**
+ * Class StreamTagsRequest
+ *
+ * @package OCA\Social\Db
+ */
+class StreamTagsRequest extends StreamTagsRequestBuilder {
+
+
+ use TStringTools;
+
+
+ /**
+ * @param Stream $stream
+ */
+ public function generateStreamTags(Stream $stream) {
+ $hashtags = $stream->getTags();
+
+ $this->miscService->log('$$$$ ' . json_encode($hashtags));
+ foreach ($hashtags as $hashtag) {
+ $tag = $this->get('name', $hashtag);
+ if ($this->get('type', $hashtag) !== 'Hashtag' || $tag === '') {
+ continue;
+ }
+
+ $tag = substr($tag, 1);
+ $qb = $this->getStreamTagsInsertSql();
+ $streamId = $qb->prim($stream->getId());
+ $qb->setValue('stream_id', $qb->createNamedParameter($streamId));
+ $qb->setValue('hashtag', $qb->createNamedParameter($tag));
+ try {
+ $qb->execute();
+ } catch (UniqueConstraintViolationException $e) {
+ \OC::$server->getLogger()
+ ->log(1, 'Social - Duplicate hashtag on Stream ' . json_encode($stream));
+ }
+ }
+ }
+
+}
+
diff --git a/lib/Db/StreamTagsRequestBuilder.php b/lib/Db/StreamTagsRequestBuilder.php
new file mode 100644
index 00000000..25fe9f67
--- /dev/null
+++ b/lib/Db/StreamTagsRequestBuilder.php
@@ -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\Db;
+
+
+use daita\MySmallPhpTools\Traits\TArrayTools;
+use OCP\DB\QueryBuilder\IQueryBuilder;
+
+
+/**
+ * Class StreamDestRequestBuilder
+ *
+ * @package OCA\Social\Db
+ */
+class StreamTagsRequestBuilder extends CoreRequestBuilder {
+
+
+ use TArrayTools;
+
+
+ /**
+ * Base of the Sql Insert request
+ *
+ * @return SocialQueryBuilder
+ */
+ protected function getStreamTagsInsertSql(): SocialQueryBuilder {
+ $qb = $this->getQueryBuilder();
+ $qb->insert(self::TABLE_STREAM_TAGS);
+
+ return $qb;
+ }
+
+
+ /**
+ * Base of the Sql Update request
+ *
+ * @return IQueryBuilder
+ */
+ protected function getStreamTagsUpdateSql(): IQueryBuilder {
+ $qb = $this->getQueryBuilder();
+ $qb->update(self::TABLE_STREAM_TAGS);
+
+ return $qb;
+ }
+
+
+ /**
+ * Base of the Sql Select request for Shares
+ *
+ * @return IQueryBuilder
+ */
+ protected function getStreamTagsSelectSql(): IQueryBuilder {
+ $qb = $this->getQueryBuilder();
+
+ /** @noinspection PhpMethodParametersCountMismatchInspection */
+ $qb->select('st.stream_id', 'st.hashtag')
+ ->from(self::TABLE_STREAM_TAGS, 'st');
+
+ $this->defaultSelectAlias = 'st';
+
+ return $qb;
+ }
+
+
+ /**
+ * Base of the Sql Delete request
+ *
+ * @return IQueryBuilder
+ */
+ protected function getStreamTagsDeleteSql(): IQueryBuilder {
+ $qb = $this->getQueryBuilder();
+ $qb->delete(self::TABLE_STREAM_TAGS);
+
+ return $qb;
+ }
+
+}
+