From ccccebcd22d889e76a0a25db9b8a74431cf58b54 Mon Sep 17 00:00:00 2001 From: Astra Logical Date: Wed, 22 Jul 2026 16:44:42 -0400 Subject: [PATCH] Enable E2EE message parsing --- Dockerfile | 13 +++++++++---- matrix_keycloak_bot.py | 6 +++++- requirements.txt | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 00cf84d..6a26403 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,25 @@ FROM python:3.12-slim -# Prevent Python from writing .pyc files and buffer stdout/stderr for clean logging ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 WORKDIR /app -# Install dependencies first to leverage Docker layer caching +# Install libolm C library and build dependencies for E2E crypto bindings +RUN apt-get update && apt-get install -y --no-install-recommends \ + libolm-dev \ + gcc \ + python3-dev \ + && rm -rf /var/lib/apt/lists/* + COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -# Copy application source code COPY matrix_keycloak_bot.py . -# Security best practice: run as a non-root user +# Create the store directory for Olm/Megolm key databases RUN useradd -m -u 10001 botuser && \ + mkdir -p /app/store && \ chown -R botuser:botuser /app USER botuser diff --git a/matrix_keycloak_bot.py b/matrix_keycloak_bot.py index 6d1e9dc..43977f5 100644 --- a/matrix_keycloak_bot.py +++ b/matrix_keycloak_bot.py @@ -241,7 +241,11 @@ async def on_reaction(client: AsyncClient, room: MatrixRoom, event: ReactionEven # Main Event Loop # ------------------------------------------------------------------------------ async def main(): - client = AsyncClient(MATRIX_HOMESERVER, MATRIX_BOT_USER) + client = AsyncClient( + MATRIX_HOMESERVER, + MATRIX_BOT_USER, + store_path="/app/store" + ) # Register callbacks client.add_event_callback( diff --git a/requirements.txt b/requirements.txt index 4c56539..9ea4afa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -matrix-nio>=0.24.0 +matrix-nio[e2e]>=0.24.0 python-keycloak>=4.0.0