Support spec-level permalink parsing
This commit is contained in:
parent
f183e96d66
commit
baf78da791
2 changed files with 75 additions and 1 deletions
|
@ -38,4 +38,42 @@ export default class PermalinkConstructor {
|
|||
isPermalinkHost(host: string): boolean {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
parsePermalink(fullUrl: string): PermalinkParts {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
// Inspired by/Borrowed with permission from the matrix-bot-sdk:
|
||||
// https://github.com/turt2live/matrix-js-bot-sdk/blob/7c4665c9a25c2c8e0fe4e509f2616505b5b66a1c/src/Permalinks.ts#L1-L6
|
||||
export class PermalinkParts {
|
||||
roomIdOrAlias: string;
|
||||
eventId: string;
|
||||
userId: string;
|
||||
groupId: string;
|
||||
viaServers: string[];
|
||||
|
||||
constructor(roomIdOrAlias: string, eventId: string, userId: string, groupId: string, viaServers: string[]) {
|
||||
this.roomIdOrAlias = roomIdOrAlias;
|
||||
this.eventId = eventId;
|
||||
this.groupId = groupId;
|
||||
this.userId = userId;
|
||||
this.viaServers = viaServers;
|
||||
}
|
||||
|
||||
static forUser(userId: string): PermalinkParts {
|
||||
return new PermalinkParts(null, null, userId, null, null);
|
||||
}
|
||||
|
||||
static forGroup(groupId: string): PermalinkParts {
|
||||
return new PermalinkParts(null, null, null, groupId, null);
|
||||
}
|
||||
|
||||
static forRoom(roomIdOrAlias: string, viaServers: string[]): PermalinkParts {
|
||||
return new PermalinkParts(roomIdOrAlias, null, null, null, viaServers || []);
|
||||
}
|
||||
|
||||
static forEvent(roomId: string, eventId: string, viaServers: string[]): PermalinkParts {
|
||||
return new PermalinkParts(roomId, eventId, null, null, viaServers || []);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue