diff options
author | Joas Schilling <coding@schilljs.com> | 2020-10-21 09:16:42 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-10-21 09:16:42 +0200 |
commit | 89651c5233e4e5e71213f7c05c1d94e23937e171 (patch) | |
tree | 1d2f45982c230df56f30307393a366b9c72283b6 /lib/private/Comments | |
parent | 326640462b7d04f6bbbc57858e8f978c9c46afcc (diff) | |
download | nextcloud-server-89651c5233e4e5e71213f7c05c1d94e23937e171.tar.gz nextcloud-server-89651c5233e4e5e71213f7c05c1d94e23937e171.zip |
Allow to search on multiple objects with one query
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r-- | lib/private/Comments/Manager.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index 9e31f448338..1077ea554de 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -521,6 +521,25 @@ class Manager implements ICommentsManager { * @return IComment[] */ public function search(string $search, string $objectType, string $objectId, string $verb, int $offset, int $limit = 50): array { + $objectIds = []; + if ($objectId) { + $objectIds[] = $objectIds; + } + return $this->searchForObjects($search, $objectType, $objectIds, $verb, $offset, $limit); + } + + /** + * Search for comments on one or more objects with a given content + * + * @param string $search content to search for + * @param string $objectType Limit the search by object type + * @param array $objectIds Limit the search by object ids + * @param string $verb Limit the verb of the comment + * @param int $offset + * @param int $limit + * @return IComment[] + */ + public function searchForObjects(string $search, string $objectType, array $objectIds, string $verb, int $offset, int $limit = 50): array { $query = $this->dbConn->getQueryBuilder(); $query->select('*') @@ -535,8 +554,8 @@ class Manager implements ICommentsManager { if ($objectType !== '') { $query->andWhere($query->expr()->eq('object_type', $query->createNamedParameter($objectType))); } - if ($objectId !== '') { - $query->andWhere($query->expr()->eq('object_id', $query->createNamedParameter($objectId))); + if (!empty($objectIds)) { + $query->andWhere($query->expr()->in('object_id', $query->createNamedParameter($objectIds, IQueryBuilder::PARAM_STR_ARRAY))); } if ($verb !== '') { $query->andWhere($query->expr()->eq('verb', $query->createNamedParameter($verb))); |