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/app/statistics/server/methods/getStatistics.js

22 lines
620 B

import { Meteor } from 'meteor/meteor';
import { hasPermission } from '../../../authorization';
import { Statistics } from '../../../models';
import { statistics } from '../statisticsNamespace';
Meteor.methods({
getStatistics(refresh) {
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getStatistics' });
}
if (hasPermission(Meteor.userId(), 'view-statistics') !== true) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'getStatistics' });
}
if (refresh) {
return statistics.save();
}
return Statistics.findLast();
},
});