diff --git a/src/commands/interface-manager/CommandReader.ts b/src/commands/interface-manager/CommandReader.ts index ac0014bb..283834ec 100644 --- a/src/commands/interface-manager/CommandReader.ts +++ b/src/commands/interface-manager/CommandReader.ts @@ -3,7 +3,7 @@ * All rights reserved. */ -import { MatrixRoomReference, Permalinks, UserID, isError, isStringRoomAlias, isStringRoomID } from "matrix-protection-suite"; +import { MatrixEventReference, MatrixRoomReference, Permalinks, UserID, isError, isStringRoomAlias, isStringRoomID } from "matrix-protection-suite"; export interface ISuperCoolStream { readonly source: T @@ -136,7 +136,7 @@ function readItem(stream: StringStream): ReadItem { type ReadMacro = (stream: StringStream) => ReadItem; const WORD_DISPATCH_CHARACTERS = new Map(); -export type ReadItem = string | MatrixRoomReference | UserID | Keyword; +export type ReadItem = string | MatrixRoomReference | UserID | Keyword | MatrixEventReference; /** * Defines a read macro to produce a read item. @@ -276,8 +276,12 @@ definePostReadReplace(/^https:\/\/matrix\.to/, input => { } const url = parseResult.ok; if (url.eventID !== undefined) { - // don't know what to turn event references into yet. - return input; + const eventResult = MatrixEventReference.fromPermalink(input); + if (isError(eventResult)) { + return input; + } else { + return eventResult.ok; + } } else if (url.userID !== undefined) { return new UserID(url.userID); } else { diff --git a/src/commands/interface-manager/MatrixPresentations.tsx b/src/commands/interface-manager/MatrixPresentations.tsx index 1fdb1325..7b0f5b0d 100644 --- a/src/commands/interface-manager/MatrixPresentations.tsx +++ b/src/commands/interface-manager/MatrixPresentations.tsx @@ -9,7 +9,7 @@ import { UserID } from "matrix-bot-sdk"; import { definePresentationRenderer } from "./DeadDocumentPresentation"; import { JSXFactory } from "./JSXFactory"; import { DocumentNode } from "./DeadDocument"; -import { MatrixRoomAlias, MatrixRoomID } from "matrix-protection-suite"; +import { MatrixEventViaAlias, MatrixEventViaRoomID, MatrixRoomAlias, MatrixRoomID } from "matrix-protection-suite"; makePresentationType({ @@ -38,3 +38,8 @@ definePresentationRenderer(findPresentationType('UserID'), function (presentatio {presentation.toString()} }) + +makePresentationType({ + name: 'MatrixEventReference', + validator: simpleTypeValidator('MatrixEventReference', (item) => item instanceof MatrixEventViaAlias || item instanceof MatrixEventViaRoomID) +})