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/statistics/server/functions/getLastStatistics.ts

16 lines
543 B

import type { IUser } from '@rocket.chat/core-typings';
import { Statistics } from '@rocket.chat/models';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { statistics } from '../lib/statistics';
export async function getLastStatistics({ userId, refresh }: { userId: IUser['_id']; refresh?: boolean }) {
if (!(await hasPermissionAsync(userId, 'view-statistics'))) {
throw new Error('error-not-allowed');
}
if (refresh) {
return statistics.save();
}
return Statistics.findLast();
}