diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 9dcf8eb2..1e5dacd3 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -200,6 +200,15 @@ class CoreRequestBuilder { } + /** + * @param IQueryBuilder $qb + * @param string $type + */ + protected function filterType(IQueryBuilder $qb, string $type) { + $this->filterDBField($qb, 'type', $type); + } + + /** * Limit the request to the Preferred Username * @@ -484,14 +493,29 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $field * @param string $value - * @param bool $eq + * @param bool $cs - case sensitive + * @param string $alias + */ + protected function filterDBField( + IQueryBuilder &$qb, string $field, string $value, bool $cs = true, string $alias = '' + ) { + $expr = $this->exprLimitToDBField($qb, $field, $value, false, $cs, $alias); + $qb->andWhere($expr); + } + + + /** + * @param IQueryBuilder $qb + * @param string $field + * @param string $value + * @param bool $eq - true = limit, false = filter * @param bool $cs * @param string $alias * * @return string */ protected function exprLimitToDBField( - IQueryBuilder &$qb, string $field, string $value, bool $eq = true, bool $cs = true, + IQueryBuilder &$qb, string $field, string $value, bool $eq, bool $cs = true, string $alias = '' ): string { $expr = $qb->expr(); @@ -502,9 +526,8 @@ class CoreRequestBuilder { } $field = $pf . $field; - if ($eq) { - $comp = 'eq'; - } else { + $comp = 'eq'; + if (!$eq) { $comp = 'neq'; } diff --git a/lib/Db/StreamRequest.php b/lib/Db/StreamRequest.php index 1e482739..9eda3647 100644 --- a/lib/Db/StreamRequest.php +++ b/lib/Db/StreamRequest.php @@ -40,8 +40,10 @@ use OCA\Social\Exceptions\DateTimeException; use OCA\Social\Exceptions\ItemUnknownException; use OCA\Social\Exceptions\SocialAppConfigException; use OCA\Social\Exceptions\StreamNotFoundException; +use OCA\Social\Interfaces\Internal\SocialAppNotificationInterface; use OCA\Social\Model\ActivityPub\ACore; use OCA\Social\Model\ActivityPub\Actor\Person; +use OCA\Social\Model\ActivityPub\Internal\SocialAppNotification; use OCA\Social\Model\ActivityPub\Object\Note; use OCA\Social\Model\ActivityPub\Stream; use OCA\Social\Service\ConfigService; @@ -321,6 +323,7 @@ class StreamRequest extends StreamRequestBuilder { $this->limitPaginate($qb, $since, $limit); $this->limitToRecipient($qb, $actor->getId(), false); + $this->limitToType($qb, SocialAppNotification::TYPE); $this->leftJoinCacheActors($qb, 'attributed_to'); $this->leftJoinStreamAction($qb); @@ -394,6 +397,7 @@ class StreamRequest extends StreamRequestBuilder { $this->limitToRecipient($qb, $actor->getId(), true); $this->filterRecipient($qb, ACore::CONTEXT_PUBLIC); $this->filterRecipient($qb, $actor->getFollowers()); + $this->filterType($qb, SocialAppNotification::TYPE); // $this->filterHiddenOnTimeline($qb); $this->leftJoinCacheActors($qb, 'attributed_to'); diff --git a/lib/Db/StreamRequestBuilder.php b/lib/Db/StreamRequestBuilder.php index 003660d5..f0f5fe51 100644 --- a/lib/Db/StreamRequestBuilder.php +++ b/lib/Db/StreamRequestBuilder.php @@ -244,9 +244,7 @@ class StreamRequestBuilder extends CoreRequestBuilder { // all possible follow, but linked by followers (actor_id) and accepted follow $crossFollows = $expr->andX(); $crossFollows->add($recipientFields); - $crossFollows->add( - $this->exprLimitToDBField($qb, 'actor_id', $actor->getId(), true, false, 'f') - ); + $crossFollows->add($this->exprLimitToDBField($qb, 'actor_id', $actor->getId(),true, false, 'f')); $crossFollows->add($this->exprLimitToDBFieldInt($qb, 'accepted', 1, 'f')); $on->add($crossFollows); diff --git a/src/App.vue b/src/App.vue index c5633cf6..69c657dc 100644 --- a/src/App.vue +++ b/src/App.vue @@ -136,6 +136,16 @@ export default { icon: 'icon-comment', text: t('social', 'Direct messages') }, + { + id: 'social-notifications', + classes: [], + router: { + name: 'timeline', + params: { type: 'notifications' } + }, + icon: 'icon-comment', + text: t('social', 'Notifications') + }, { id: 'social-account', classes: [],