2021-06-15 20:13:42 +00:00
|
|
|
import { getSubscriptionByRoomId } from '../database/services/Subscription';
|
|
|
|
import RocketChat from '../rocketchat';
|
|
|
|
|
2021-10-01 18:12:19 +00:00
|
|
|
const getRoomInfo = async rid => {
|
2021-06-15 20:13:42 +00:00
|
|
|
let result;
|
|
|
|
result = await getSubscriptionByRoomId(rid);
|
|
|
|
if (result) {
|
|
|
|
return {
|
|
|
|
rid,
|
|
|
|
name: result.name,
|
|
|
|
fname: result.fname,
|
|
|
|
t: result.t
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
result = await RocketChat.getRoomInfo(rid);
|
|
|
|
if (result?.success) {
|
|
|
|
return {
|
|
|
|
rid,
|
|
|
|
name: result.room.name,
|
|
|
|
fname: result.room.fname,
|
|
|
|
t: result.room.t
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default getRoomInfo;
|