aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2022-07-05 13:14:05 +0200
committerGitHub <noreply@github.com>2022-07-05 13:14:05 +0200
commit991ff3c99c8bf9a407d62f06f09cc147495755a8 (patch)
treec056deabacdaeeb34512a783dde47279079a3e09 /lib
parentb5b4ab40af63f25f322b65f92cfa2c731827c2ef (diff)
parentd722a0c12aefa0f6458c2f519f3627dc1cea89e0 (diff)
downloadnextcloud-server-991ff3c99c8bf9a407d62f06f09cc147495755a8.tar.gz
nextcloud-server-991ff3c99c8bf9a407d62f06f09cc147495755a8.zip
Merge pull request #33086 from nextcloud/techdebt/noid/allow-expiring-comments-of-multiple-objects-in-one-go
Allow to expire comments of multiple objects with one call
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Comments/Manager.php14
-rw-r--r--lib/public/Comments/ICommentsManager.php4
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index f21f9ec76b2..50b5fabc6a2 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -1650,14 +1650,18 @@ class Manager implements ICommentsManager {
/**
* @inheritDoc
*/
- public function deleteMessageExpiredAtObject(string $objectType, string $objectId): bool {
+ public function deleteCommentsExpiredAtObject(string $objectType, string $objectId = ''): bool {
$qb = $this->dbConn->getQueryBuilder();
- $affectedRows = $qb->delete('comments')
+ $qb->delete('comments')
->where($qb->expr()->lt('expire_date',
$qb->createNamedParameter($this->timeFactory->getDateTime(), IQueryBuilder::PARAM_DATE)))
- ->andWhere($qb->expr()->eq('object_type', $qb->createNamedParameter($objectType)))
- ->andWhere($qb->expr()->eq('object_id', $qb->createNamedParameter($objectId)))
- ->executeStatement();
+ ->andWhere($qb->expr()->eq('object_type', $qb->createNamedParameter($objectType)));
+
+ if ($objectId !== '') {
+ $qb->andWhere($qb->expr()->eq('object_id', $qb->createNamedParameter($objectId)));
+ }
+
+ $affectedRows = $qb->executeStatement();
$this->commentsCache = [];
diff --git a/lib/public/Comments/ICommentsManager.php b/lib/public/Comments/ICommentsManager.php
index 814ca3e8f9c..da9e4d76a38 100644
--- a/lib/public/Comments/ICommentsManager.php
+++ b/lib/public/Comments/ICommentsManager.php
@@ -488,9 +488,9 @@ interface ICommentsManager {
* Only will delete the message related with the object.
*
* @param string $objectType the object type (e.g. 'files')
- * @param string $objectId e.g. the file id
+ * @param string $objectId e.g. the file id, leave empty to expire on all objects of this type
* @return boolean true if at least one row was deleted
* @since 25.0.0
*/
- public function deleteMessageExpiredAtObject(string $objectType, string $objectId): bool;
+ public function deleteCommentsExpiredAtObject(string $objectType, string $objectId = ''): bool;
}