Add redimentary group support
This commit is contained in:
@@ -24,10 +24,12 @@ import {
|
||||
Room,
|
||||
RoomAlias,
|
||||
User,
|
||||
Group,
|
||||
getRoomIdFromAlias,
|
||||
searchPublicRooms,
|
||||
getUserDetails,
|
||||
convertMXCtoMediaQuery,
|
||||
getGroupDetails,
|
||||
} from '../matrix-cypher';
|
||||
import { LinkKind, Permalink } from '../parser/types';
|
||||
|
||||
@@ -72,6 +74,11 @@ export const fallbackRoom = ({
|
||||
};
|
||||
};
|
||||
|
||||
export const fallbackGroup = (groupId: string): Group => ({
|
||||
name: groupId,
|
||||
short_description: `The ${groupId} group`,
|
||||
});
|
||||
|
||||
/*
|
||||
* Tries to fetch room details from an alias. If it fails it uses
|
||||
* a `fallbackRoom`
|
||||
@@ -169,3 +176,15 @@ export function getMediaQueryFromMCX(mxc?: string): string {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
export async function getGroup(
|
||||
clientURL: string,
|
||||
groupId: string
|
||||
): Promise<Group> {
|
||||
try {
|
||||
const resolvedClient = await client(clientURL);
|
||||
return await getGroupDetails(resolvedClient, groupId);
|
||||
} catch {
|
||||
return fallbackGroup(groupId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user