The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/app/api/server/v1/instances.ts

44 lines
1.0 KiB

import { InstanceStatus } from '@rocket.chat/models';
import { isRunningMs } from '../../../../server/lib/isRunningMs';
import { API } from '../api';
import { getInstanceList } from '../helpers/getInstanceList';
const getConnections = (() => {
if (isRunningMs()) {
return () => [];
}
return () => getInstanceList();
})();
API.v1.addRoute(
'instances.get',
{ authRequired: true, permissionsRequired: ['view-statistics'] },
{
async get() {
const instanceRecords = await InstanceStatus.find().toArray();
const connections = await getConnections();
const result = instanceRecords.map((instanceRecord) => {
const connection = connections.find((c) => c.id === instanceRecord._id);
return {
address: connection?.ipList[0],
currentStatus: {
connected: connection?.available || false,
lastHeartbeatTime: connection?.lastHeartbeatTime,
local: connection?.local,
},
instanceRecord,
broadcastAuth: true,
};
});
return API.v1.success({
instances: result,
});
},
},
);