mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-07 15:53:13 +08:00
Created new service to resolve short URLs
This commit is contained in:
@@ -146,8 +146,6 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI
|
||||
FROM Shlinkio\Shlink\Core\Entity\ShortUrl AS s
|
||||
LEFT JOIN s.domain AS d
|
||||
WHERE s.shortCode = :shortCode
|
||||
AND (s.validSince <= :now OR s.validSince IS NULL)
|
||||
AND (s.validUntil >= :now OR s.validUntil IS NULL)
|
||||
AND (s.domain IS NULL OR d.authority = :domain)
|
||||
ORDER BY s.domain {$ordering}
|
||||
DQL;
|
||||
@@ -156,7 +154,6 @@ DQL;
|
||||
$query->setMaxResults(1)
|
||||
->setParameters([
|
||||
'shortCode' => $shortCode,
|
||||
'now' => Chronos::now(),
|
||||
'domain' => $domain,
|
||||
]);
|
||||
|
||||
@@ -166,9 +163,7 @@ DQL;
|
||||
// * The short URL matching the short code but without any domain, or
|
||||
// * No short URL at all
|
||||
|
||||
/** @var ShortUrl|null $shortUrl */
|
||||
$shortUrl = $query->getOneOrNullResult();
|
||||
return $shortUrl !== null && ! $shortUrl->maxVisitsReached() ? $shortUrl : null;
|
||||
return $query->getOneOrNullResult();
|
||||
}
|
||||
|
||||
public function shortCodeIsInUse(string $slug, ?string $domain = null): bool
|
||||
|
||||
Reference in New Issue
Block a user