refator(socket.io): deprecate socketGroups.getChatGroups in favour of api.admin.listGroups

This commit is contained in:
Julian Lam
2023-11-08 15:10:44 -05:00
parent 181a93996c
commit dc4cc74fbd
9 changed files with 73 additions and 11 deletions

View File

@@ -3,6 +3,7 @@
const meta = require('../meta');
const analytics = require('../analytics');
const privileges = require('../privileges');
const groups = require('../groups');
const adminApi = module.exports;
@@ -34,3 +35,11 @@ adminApi.getAnalyticsData = async (caller, { set, until, amount, units }) => {
const getStats = units === 'days' ? analytics.getDailyStatsForSet : analytics.getHourlyStatsForSet;
return await getStats(`analytics:${set}`, parseInt(until, 10) || Date.now(), amount);
};
adminApi.listGroups = async () => {
// N.B. Returns all groups, even hidden. Beware of leakage.
// Access control handled at controller level
const payload = await groups.getNonPrivilegeGroups('groups:createtime', 0, -1, { ephemeral: false });
return { groups: payload };
};