diff options
Diffstat (limited to 'lib/Db/NewsMapperV2.php')
-rw-r--r-- | lib/Db/NewsMapperV2.php | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/Db/NewsMapperV2.php b/lib/Db/NewsMapperV2.php index 5d1905151..cbfb84fde 100644 --- a/lib/Db/NewsMapperV2.php +++ b/lib/Db/NewsMapperV2.php @@ -64,16 +64,30 @@ abstract class NewsMapperV2 extends QBMapper } /** - * Remove deleted items. + * Remove deleted entities. + * + * @param string|null $userID The user to purge + * @param int|null $oldestDelete The timestamp to purge from * * @return void */ - public function purgeDeleted(): void + public function purgeDeleted(?string $userID, ?int $oldestDelete): void { $builder = $this->db->getQueryBuilder(); $builder->delete($this->tableName) - ->where('deleted_at != 0') - ->execute(); + ->andWhere('deleted_at != 0'); + + if ($userID !== null) { + $builder->andWhere('user_id = :user_id') + ->setParameter(':user_id', $userID); + } + + if ($oldestDelete !== null) { + $builder->andWhere('deleted_at < :deleted_at') + ->setParameter(':deleted_at', $oldestDelete); + } + + $builder->execute(); } /** |