Fixed visits with loading screen
This commit is contained in:
parent
5f4d4aeb73
commit
0285b95518
@ -40,6 +40,8 @@ async def _handle_request(path: str):
|
||||
return await _handle_short_url(path, short_url)
|
||||
|
||||
if short_url.loading_screen:
|
||||
await _track_visit(short_url)
|
||||
|
||||
return render_template(
|
||||
"redirect.html",
|
||||
key=short_url.short_url,
|
||||
@ -53,6 +55,11 @@ async def _handle_short_url(path: str, short_url: ShortUrl):
|
||||
if path.startswith("api/"):
|
||||
path = path.replace("api/", "")
|
||||
|
||||
await _track_visit(short_url)
|
||||
|
||||
return _do_redirect(short_url.target_url)
|
||||
|
||||
async def _track_visit(short_url: ShortUrl):
|
||||
try:
|
||||
await shortUrlVisitDao.create(
|
||||
ShortUrlVisit(0, short_url.id, request.headers.get("User-Agent"))
|
||||
@ -60,9 +67,6 @@ async def _handle_short_url(path: str, short_url: ShortUrl):
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to update short url {short_url.short_url} with error", e)
|
||||
|
||||
return _do_redirect(short_url.target_url)
|
||||
|
||||
|
||||
async def _find_short_url_by_url(url: str) -> ShortUrl:
|
||||
return await shortUrlDao.find_single_by({ShortUrl.short_url: url})
|
||||
|
||||
|
@ -1 +1 @@
|
||||
1.0.0
|
||||
1.0.1
|
Loading…
Reference in New Issue
Block a user