mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-10-23 09:22:24 +00:00
Add MatrixEventReference to presentation types.
This commit is contained in:
1 parent
76a58b6f00
commit
f6771b06cf
2 files changed
+14
-5
No files matched your search
@@ -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<T> {
|
||||
readonly source: T
|
||||
@@ -136,7 +136,7 @@ function readItem(stream: StringStream): ReadItem {
|
||||
type ReadMacro = (stream: StringStream) => ReadItem;
|
||||
|
||||
const WORD_DISPATCH_CHARACTERS = new Map<string, ReadMacro>();
|
||||
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 {
|
||||
|
||||
@@ -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()}
|
||||
</a>
|
||||
})
|
||||
|
||||
makePresentationType({
|
||||
name: 'MatrixEventReference',
|
||||
validator: simpleTypeValidator('MatrixEventReference', (item) => item instanceof MatrixEventViaAlias || item instanceof MatrixEventViaRoomID)
|
||||
})
|
||||
Reference in new issue
Block a user