Compare commits

..

No commits in common. "a9f763c6493ba422fb6219f304851014834eb54a" and "0985bd3073b2fd3746d24bd0dd803798a42f7213" have entirely different histories.

6 changed files with 6 additions and 39 deletions

View File

@ -30,31 +30,6 @@ jobs:
- name: Push image - name: Push image
run: | run: |
docker push git.sh-edraft.de/sh-edraft.de/open-redirect-api:$(cat version.txt) 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: build-web:
runs-on: [runner] runs-on: [runner]

View File

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

View File

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

View File

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

View File

@ -40,8 +40,6 @@ async def _handle_request(path: str):
return await _handle_short_url(path, short_url) return await _handle_short_url(path, short_url)
if short_url.loading_screen: if short_url.loading_screen:
await _track_visit(short_url)
return render_template( return render_template(
"redirect.html", "redirect.html",
key=short_url.short_url, key=short_url.short_url,
@ -55,11 +53,6 @@ async def _handle_short_url(path: str, short_url: ShortUrl):
if path.startswith("api/"): if path.startswith("api/"):
path = path.replace("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: try:
await shortUrlVisitDao.create( await shortUrlVisitDao.create(
ShortUrlVisit(0, short_url.id, request.headers.get("User-Agent")) ShortUrlVisit(0, short_url.id, request.headers.get("User-Agent"))
@ -67,6 +60,9 @@ async def _track_visit(short_url: ShortUrl):
except Exception as e: except Exception as e:
logger.error(f"Failed to update short url {short_url.short_url} with error", 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: async def _find_short_url_by_url(url: str) -> ShortUrl:
return await shortUrlDao.find_single_by({ShortUrl.short_url: url}) return await shortUrlDao.find_single_by({ShortUrl.short_url: url})

View File

@ -1 +1 @@
1.0.4 0.3.1