2022-03-29 18:53:27 +00:00
|
|
|
import { IServerSubscription, RoomType } from '../../definitions';
|
2021-06-15 20:13:42 +00:00
|
|
|
import { getSubscriptionByRoomId } from '../database/services/Subscription';
|
2022-05-30 22:01:25 +00:00
|
|
|
import { Services } from '../services';
|
2021-06-15 20:13:42 +00:00
|
|
|
|
2022-03-29 18:53:27 +00:00
|
|
|
export interface IRoomInfoResult {
|
|
|
|
rid: IServerSubscription['rid'];
|
|
|
|
name: IServerSubscription['name'];
|
|
|
|
fname: IServerSubscription['fname'];
|
|
|
|
t: IServerSubscription['t'];
|
|
|
|
}
|
|
|
|
|
|
|
|
const getRoomInfo = async (rid: string): Promise<IRoomInfoResult | null> => {
|
2021-06-15 20:13:42 +00:00
|
|
|
let result;
|
|
|
|
result = await getSubscriptionByRoomId(rid);
|
|
|
|
if (result) {
|
|
|
|
return {
|
|
|
|
rid,
|
|
|
|
name: result.name,
|
|
|
|
fname: result.fname,
|
2022-03-29 18:53:27 +00:00
|
|
|
t: result.t as RoomType
|
2021-06-15 20:13:42 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-05-30 22:01:25 +00:00
|
|
|
result = await Services.getRoomInfo(rid);
|
2021-06-15 20:13:42 +00:00
|
|
|
if (result?.success) {
|
|
|
|
return {
|
|
|
|
rid,
|
2022-03-29 18:53:27 +00:00
|
|
|
name: result.room.name as string,
|
2021-06-15 20:13:42 +00:00
|
|
|
fname: result.room.fname,
|
|
|
|
t: result.room.t
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default getRoomInfo;
|