fix(events): envolver VEVENT en VCALENDAR al push (Xandikos 500) + INSERT explicito en contacts (columna import_key)

El raw de un evento guardaba solo BEGIN:VEVENT...END:VEVENT; subirlo a CalDAV
genera un .ics invalido que rompe Xandikos (assert isinstance(cal, Calendar) ->
500 en todo el calendario). _ensure_vcalendar lo envuelve en el push. Ademas, la
columna import_key (migracion 004) rompia los INSERT posicionales de contacts:
ahora son explicitos por columna y el ingest puebla import_key con la funcion del
registry. Tests actualizados (4 derivadas, INSERT explicito).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 12:15:27 +02:00
parent 36c4e06779
commit d53d7a9a7e
4 changed files with 49 additions and 9 deletions
+7 -1
View File
@@ -30,6 +30,7 @@ from .config import Config
from .db import write_conn
from .derived import rebuild_derived
from .registry_bridge import (
contact_import_key,
dav_get_collection,
dav_list_addressbooks,
dav_list_calendars,
@@ -450,6 +451,9 @@ def ingest_dav(cfg: Config) -> dict:
res.get("data", ""),
None, # note_path se rellena en el enlace posterior
now,
# Clave de importación determinística: nace con el contacto
# para que los re-imports lo localicen sin match frágil.
contact_import_key(parsed["fn"] or "", parsed["tels"], parsed["emails"]),
]
)
@@ -503,7 +507,9 @@ def ingest_dav(cfg: Config) -> dict:
conn.execute("DELETE FROM contacts")
if contact_rows:
conn.executemany(
"INSERT INTO contacts VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
"INSERT INTO contacts (uid, collection, etag, fn, tels, "
"emails, raw, note_path, updated_at, import_key) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
contact_rows,
)
conn.execute("DELETE FROM events")