refactor(#356): DSAR-Fachlogik vollstaendig aus dem Core extrahiert — dsar_collect/dsar_erase in die 5 beteiligten Contracts (contacts, mail, tasks, calendar, kommunikation); core/jobs.py sammelt/loescht nur Core-eigene Daten und iteriert generisch ueber die Plugin-Registry; neue Plugins liefern DSAR-Kategorien ohne Core-Aenderung; Counts-/Category-Keys unveraendert; tasks/contracts.py von Patch-Artefakt bereinigt
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
fixes #356
This commit is contained in:
@@ -13,6 +13,11 @@ instead of importing from internal modules directly.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.plugins.builtins.contracts import get_contract_registry
|
||||
from app.plugins.builtins.kommunikation.miniapp_registry import (
|
||||
MiniAppDef,
|
||||
@@ -74,6 +79,31 @@ class KommunikationContract:
|
||||
CommMessage = CommMessage
|
||||
CommParticipant = CommParticipant
|
||||
|
||||
@staticmethod
|
||||
async def dsar_collect(
|
||||
db: AsyncSession, tenant_id: Any, user_id: Any
|
||||
) -> dict[str, Any]:
|
||||
"""GDPR Art. 15: collect communication messages sent by the user."""
|
||||
comm_messages = (
|
||||
await db.execute(
|
||||
select(CommMessage).where(
|
||||
CommMessage.sender_id == user_id,
|
||||
CommMessage.tenant_id == tenant_id,
|
||||
).limit(1000)
|
||||
)
|
||||
).scalars().all()
|
||||
return {
|
||||
"comm_messages": [
|
||||
{
|
||||
"id": str(m.id),
|
||||
"sender_type": m.sender_type,
|
||||
"content": m.content[:500],
|
||||
"created_at": m.created_at.isoformat() if m.created_at else None,
|
||||
}
|
||||
for m in comm_messages
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
# ─── self-registration ───
|
||||
|
||||
|
||||
Reference in New Issue
Block a user