feat(webhooks): add Deck card sync preset with vector indexing

Nextcloud Deck PR #7910 added IWebhookCompatibleEvent to CardCreated/
Updated/DeletedEvent and BoardUpdatedEvent, so Deck can finally emit
real-time webhooks via core's webhook_listeners app. Wire this into
the existing preset → parser → DocumentTask pipeline that already
backs Notes / Calendar / Tables / Forms / Files sync.

- Add deck_sync preset (app=deck, 4 events) and drop the stale
  "Deck does not support webhooks" comment.
- Teach webhook_parser to convert Deck card events into
  DocumentTask(doc_type=deck_card, operation=index|delete) with
  stack_id metadata. BoardUpdatedEvent logs delivery at INFO and
  returns None — the polling scanner reconciles affected cards.
- Cover three new unit tests for the deck create/delete/board-update
  paths plus symmetric fail-open tests for missing card.id /
  node.id in _parse_deck_event and _parse_file_event.

The astrolabe admin UI auto-discovers the new preset via
filter_presets_by_installed_apps(); no astrolabe-side wiring is
required for it to appear in the Webhook Management card grid.

Note: requires Deck ≥1.18.x (where PR #7910 lands); the preset is
hidden when the Deck app isn't installed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-05-21 09:03:59 +02:00
co-authored by Claude Opus 4.7
parent 0c499de6ab
commit fdcbd7bd3f
4 changed files with 286 additions and 11 deletions
+40 -4
View File
@@ -11,15 +11,16 @@ from nextcloud_mcp_server.server.webhook_presets import (
@pytest.mark.unit
def test_list_all_presets():
"""Test listing all presets returns 5 presets."""
"""Test listing all presets returns the full preset catalogue."""
presets = list_presets()
assert len(presets) == 5
assert len(presets) == 6
preset_ids = [preset_id for preset_id, _ in presets]
assert "notes_sync" in preset_ids
assert "calendar_sync" in preset_ids
assert "tables_sync" in preset_ids
assert "forms_sync" in preset_ids
assert "files_sync" in preset_ids
assert "deck_sync" in preset_ids
@pytest.mark.unit
@@ -42,15 +43,50 @@ def test_get_preset_nonexistent():
@pytest.mark.unit
def test_filter_presets_all_apps_installed():
"""Test filtering when all apps are installed."""
installed_apps = ["notes", "calendar", "tables", "forms"]
installed_apps = ["notes", "calendar", "tables", "forms", "deck"]
filtered = filter_presets_by_installed_apps(installed_apps)
assert len(filtered) == 5 # All 5 presets (files is always included)
assert len(filtered) == 6 # All 6 presets (files is always included)
preset_ids = [preset_id for preset_id, _ in filtered]
assert "notes_sync" in preset_ids
assert "calendar_sync" in preset_ids
assert "tables_sync" in preset_ids
assert "forms_sync" in preset_ids
assert "files_sync" in preset_ids
assert "deck_sync" in preset_ids
@pytest.mark.unit
def test_filter_presets_deck_included_when_installed():
"""Test that the deck preset is included when the Deck app is installed."""
installed_apps = ["deck"]
filtered = filter_presets_by_installed_apps(installed_apps)
preset_ids = [preset_id for preset_id, _ in filtered]
assert "deck_sync" in preset_ids
assert len(filtered) == 2 # deck + files
@pytest.mark.unit
def test_filter_presets_deck_excluded_when_not_installed():
"""Test that the deck preset is excluded when the Deck app is not installed."""
installed_apps = ["notes", "calendar", "tables", "forms"]
filtered = filter_presets_by_installed_apps(installed_apps)
preset_ids = [preset_id for preset_id, _ in filtered]
assert "deck_sync" not in preset_ids
@pytest.mark.unit
def test_get_deck_preset():
"""Test getting the deck_sync preset returns the expected shape."""
preset = get_preset("deck_sync")
assert preset is not None
assert preset["app"] == "deck"
assert preset["name"] == "Deck Sync"
assert len(preset["events"]) == 4
event_classes = [e["event"] for e in preset["events"]]
assert "OCA\\Deck\\Event\\CardCreatedEvent" in event_classes
assert "OCA\\Deck\\Event\\CardUpdatedEvent" in event_classes
assert "OCA\\Deck\\Event\\CardDeletedEvent" in event_classes
assert "OCA\\Deck\\Event\\BoardUpdatedEvent" in event_classes
@pytest.mark.unit