vojo/apps/widget-discord/src/bridge-protocol/parser.ts

18 lines
910 B
TypeScript

// Parser shim. The widget consumes a single `parseEvent(rawEvent)` and
// the dialect handles the full event surface — m.text, m.notice, m.image
// (QR broadcasts), m.room.redaction (post-scan cleanup). M-discord ships
// one dialect, `legacy_v076`, for the operator's current bridge image.
// When mautrix-discord eventually migrates to bridgev2 (the team flagged
// this as «not yet» as of 2026-01), add a sibling dialect file and
// switch the import below.
//
// The dialects/ subdirectory is kept as a seam for that swap; we don't
// implement runtime autodetect (the operator owns one bridge image at a
// time and a parser pin is honest about that).
import type { LoginEvent, ParsableEvent } from './types';
import { parseEventLegacyV076 } from './dialects/legacy_v076';
export type { ParsableEvent };
export const parseEvent = (event: ParsableEvent): LoginEvent => parseEventLegacyV076(event);