Compare commits

...

6 Commits

Author SHA1 Message Date
a9f763c649 Added deps of redirector
All checks were successful
Build on push / build-api (push) Successful in 6s
Build on push / build-redirector (push) Successful in 28s
Build on push / build-web (push) Successful in 48s
Build dev on push / build-redirector (push) Successful in 7s
Build dev on push / build-api (push) Successful in 8s
Build dev on push / build-web (push) Successful in 48s
2025-01-10 14:04:37 +01:00
d9eeda3c80 Added deps of redirector
All checks were successful
Build on push / build-api (push) Successful in 8s
Build on push / build-redirector (push) Successful in 31s
Build on push / build-web (push) Successful in 50s
2025-01-10 14:02:19 +01:00
335296e29d Updated dockerfiles
All checks were successful
Build on push / build-redirector (push) Successful in 28s
Build on push / build-api (push) Successful in 30s
Build on push / build-web (push) Successful in 47s
2025-01-10 13:56:11 +01:00
0285b95518 Fixed visits with loading screen
All checks were successful
Build on push / build-redirector (push) Successful in 29s
Build on push / build-api (push) Successful in 30s
Build on push / build-web (push) Successful in 1m6s
2025-01-10 13:18:38 +01:00
5f4d4aeb73 Added redirector build
All checks were successful
Build on push / build-redirector (push) Successful in 17s
Build on push / build-api (push) Successful in 19s
Build on push / build-web (push) Successful in 1m7s
2025-01-10 12:27:12 +01:00
021152bcf5 Set version 1.0.0
Some checks failed
Build on push / build-api (push) Has been cancelled
Build on push / build-web (push) Has been cancelled
2025-01-10 12:26:19 +01:00
6 changed files with 39 additions and 6 deletions

View File

@ -31,6 +31,31 @@ jobs:
run: |
docker push git.sh-edraft.de/sh-edraft.de/open-redirect-api:$(cat version.txt)
build-redirector:
runs-on: [runner]
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps:
- name: Clone Repository
uses: https://github.com/actions/checkout@v3
with:
token: ${{ secrets.CI_ACCESS_TOKEN }}
- name: Build docker
run: |
cd api
docker build -f dockerfile_redirector -t git.sh-edraft.de/sh-edraft.de/open-redirect-redirector:$(cat ../version.txt) .
- name: Login to registry git.sh-edraft.de
uses: https://github.com/docker/login-action@v1
with:
registry: git.sh-edraft.de
username: ${{ secrets.CI_USERNAME }}
password: ${{ secrets.CI_ACCESS_TOKEN }}
- name: Push image
run: |
docker push git.sh-edraft.de/sh-edraft.de/open-redirect-redirector:$(cat version.txt)
build-web:
runs-on: [runner]
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest

View File

@ -3,10 +3,14 @@ FROM python:3.12.8-alpine
WORKDIR /app
COPY ./src/api/ ./api
COPY ./src/core/ ./core
COPY ./src/data/ ./data
COPY ./src/service/ ./service
COPY ./src/static/ ./static
COPY ./src/templates/ ./templates
COPY ./src/redirector.py .
COPY ./src/redirector .

View File

@ -13,4 +13,4 @@ fi
export PYTHONPATH=./:$PYTHONPATH
python3.12 main.py
python3.12 -u main.py

View File

@ -13,4 +13,4 @@ fi
export PYTHONPATH=./:$PYTHONPATH
python3.12 redirector.py
python3.12 -u redirector.py

View File

@ -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})

View File

@ -1 +1 @@
0.3.1
1.0.4