diff options
Diffstat (limited to 'apps/dav/lib/Db/DirectMapper.php')
-rw-r--r-- | apps/dav/lib/Db/DirectMapper.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/dav/lib/Db/DirectMapper.php b/apps/dav/lib/Db/DirectMapper.php index 806b145823e..d0db4b82879 100644 --- a/apps/dav/lib/Db/DirectMapper.php +++ b/apps/dav/lib/Db/DirectMapper.php @@ -34,6 +34,11 @@ class DirectMapper extends Mapper { parent::__construct($db, 'directlink', Direct::class); } + /** + * @param string $token + * @return Direct + * @throws DoesNotExistException + */ public function getByToken(string $token): Direct { $qb = $this->db->getQueryBuilder(); @@ -48,9 +53,20 @@ class DirectMapper extends Mapper { $cursor->closeCursor(); if ($data === false) { - throw new DoesNotExistException(); + throw new DoesNotExistException('Direct link with token does not exist'); } return Direct::fromRow($data); } + + public function deleteExpired(int $expiration) { + $qb = $this->db->getQueryBuilder(); + + $qb->delete('directlink') + ->where( + $qb->expr()->lt('expiration', $qb->createNamedParameter($expiration)) + ); + + $qb->execute(); + } } |