diff --git a/VERSION b/VERSION index b0a0271..c789257 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1253 \ No newline at end of file +1254 \ No newline at end of file diff --git a/backend/routes/partner.py b/backend/routes/partner.py index b405e8a..b73ae1a 100644 --- a/backend/routes/partner.py +++ b/backend/routes/partner.py @@ -329,17 +329,22 @@ async def upload_partner_logo(file: UploadFile = File(...), user=Depends(require new_name = f"logo_{uuid.uuid4().hex[:8]}.webp" new_path = os.path.join(save_dir, new_name) + loop = asyncio.get_event_loop() + # HEIC/HEIF (iPhone) zuerst nach JPEG wandeln — Pillow kann HEIC nicht ohne Opener + data, ext = await loop.run_in_executor(None, lambda: convert_media(raw, filename)) + if ext in (".heic", ".heif"): + raise HTTPException(400, "HEIC-Bild konnte nicht konvertiert werden. Bitte als JPG/PNG exportieren.") + def _save(): import io from PIL import Image, ImageOps - img = Image.open(io.BytesIO(raw)) + img = Image.open(io.BytesIO(data)) img = ImageOps.exif_transpose(img) # Transparenz erhalten (Logos sind oft PNG mit Alpha) img = img.convert("RGBA" if "A" in (img.mode or "") or img.mode == "P" else "RGB") img.thumbnail((512, 512)) img.save(new_path, format="WEBP", quality=85) - loop = asyncio.get_event_loop() try: await loop.run_in_executor(None, _save) except Exception: @@ -394,6 +399,11 @@ async def upload_partner_photo(file: UploadFile = File(...), user=Depends(requir loop = asyncio.get_event_loop() # HEIC→JPEG bzw. MOV/AVI→MP4 (ffmpeg, komprimiert) — blockierend, daher Threadpool data, ext = await loop.run_in_executor(None, lambda: convert_media(raw, filename)) + if ext in (".heic", ".heif"): + raise HTTPException(400, "HEIC-Bild konnte nicht konvertiert werden. Bitte als JPG/PNG exportieren.") + if ext in (".mov", ".avi", ".m4v"): + # ffmpeg-Konvertierung fehlgeschlagen — unkonvertiert wäre es im Browser nicht abspielbar + raise HTTPException(400, "Video konnte nicht konvertiert werden. Bitte als MP4 hochladen.") save_dir = _pp_dir(user["id"]) file_id = uuid.uuid4().hex[:12] diff --git a/backend/static/index.html b/backend/static/index.html index 3657214..42da1ae 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -86,14 +86,14 @@ Ban Yaro - + - - - - - + + + + + @@ -612,11 +612,11 @@ - - - - - + + + + + @@ -626,7 +626,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 92a040a..a0c2263 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '1253'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '1254'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator) window.APP_VERSION = APP_VERSION; diff --git a/backend/static/landing.html b/backend/static/landing.html index 75f1905..ef59aea 100644 --- a/backend/static/landing.html +++ b/backend/static/landing.html @@ -4,7 +4,7 @@ - + Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz diff --git a/backend/static/sw.js b/backend/static/sw.js index 449fd49..6d66ba9 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -4,7 +4,7 @@ ============================================================ */ // ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab -const VER = '1253'; +const VER = '1254'; const CACHE_VERSION = `by-v${VER}`; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten diff --git a/tests/test_partner_profile.py b/tests/test_partner_profile.py index d26c26f..2dbe2d0 100644 --- a/tests/test_partner_profile.py +++ b/tests/test_partner_profile.py @@ -112,6 +112,30 @@ def test_logo_and_photo_upload(client, user): assert r.json()["photos"] == [] +def test_heic_uploads_convert(client, user): + """HEIC (iPhone-Format) wird bei Logo UND Foto nach WebP konvertiert.""" + import pillow_heif + from PIL import Image + _make_partner(user["email"]) + + pillow_heif.register_heif_opener() + buf = io.BytesIO() + Image.new("RGB", (64, 64), "green").save(buf, format="HEIF") + heic_bytes = buf.getvalue() + + # Logo als HEIC + r = client.post("/api/partner/my-profile/logo", headers=user["headers"], + files={"file": ("IMG_0001.HEIC", io.BytesIO(heic_bytes), "image/heic")}) + assert r.status_code == 200, r.text + assert r.json()["logo_url"].endswith(".webp") + + # Foto als HEIC + r = client.post("/api/partner/my-profile/photos", headers=user["headers"], + files={"file": ("IMG_0002.heic", io.BytesIO(heic_bytes), "image/heic")}) + assert r.status_code == 200, r.text + assert r.json()["photos"][0].endswith(".webp") + + def test_partner_has_pro_access(client, user): """is_partner=1 -> has_pro_access True (Pro gratis fuer Partner).""" from auth import has_pro_access