diff --git a/api/ovdashboard_api/dav_calendar.py b/api/ovdashboard_api/dav_calendar.py index 7e10dd5..cbe46b2 100644 --- a/api/ovdashboard_api/dav_calendar.py +++ b/api/ovdashboard_api/dav_calendar.py @@ -15,6 +15,8 @@ from caldav.lib.error import ReportError from pydantic import BaseModel, validator from vobject.icalendar import VEvent +from ovdashboard_api.config import Config + from .async_helpers import get_ttl_hash, run_in_executor, timed_alru_cache from .dav_common import caldav_principal from .settings import SETTINGS @@ -118,6 +120,9 @@ async def _get_calendar_events( an iterator would get consumed. """ + cfg = await Config.get() + search_span = timedelta(days=cfg.calendar.future_days) + @run_in_executor def _inner() -> Iterator[VEvent]: """ @@ -133,7 +138,7 @@ async def _get_calendar_events( date_start = datetime.utcnow().date() time_min = datetime.min.time() dt_start = datetime.combine(date_start, time_min) - dt_end = dt_start + timedelta(days=365) + dt_end = dt_start + search_span try: search_result = calendar.date_search( diff --git a/api/ovdashboard_api/routers/image.py b/api/ovdashboard_api/routers/image.py index 3e28cdf..7373f41 100644 --- a/api/ovdashboard_api/routers/image.py +++ b/api/ovdashboard_api/routers/image.py @@ -14,6 +14,7 @@ from fastapi import APIRouter, Depends from fastapi.responses import StreamingResponse from PIL import Image +from ..config import Config from ..dav_file import DavFile from ._common import FileNameLister, PrefixFinder, PrefixUnique @@ -62,11 +63,17 @@ async def get_image( prefix: str, name: str = Depends(_unique), ) -> str: + cfg = await Config.get() + dav_file = DavFile(f"{_lister.remote_path}/{name}") - img = Image.open(BytesIO(await dav_file.bytes)).convert("RGB") + img = Image.open( + BytesIO(await dav_file.bytes) + ).convert( + cfg.image.mode + ) img_buffer = BytesIO() - img.save(img_buffer, format="JPEG", quality=85) + img.save(img_buffer, **cfg.image.save_params) img_buffer.seek(0) return StreamingResponse(