You've already forked peertube-plugin-hide-root-user
57 lines
1.1 KiB
JavaScript
57 lines
1.1 KiB
JavaScript
async function register ({
|
|
registerHook,
|
|
registerSetting,
|
|
settingsManager,
|
|
storageManager,
|
|
videoCategoryManager,
|
|
videoLicenceManager,
|
|
videoLanguageManager,
|
|
}) {
|
|
registerHook({
|
|
target: 'filter:api.server.stats.get.result',
|
|
handler: (data) => {
|
|
if (!data) return {};
|
|
|
|
let {
|
|
totalUsers,
|
|
totalDailyActiveUsers,
|
|
totalWeeklyActiveUsers,
|
|
totalMonthlyActiveUsers,
|
|
} = data;
|
|
|
|
if (totalUsers > 1) {
|
|
totalUsers = totalUsers - 1;
|
|
}
|
|
|
|
if (totalDailyActiveUsers > totalUsers) {
|
|
totalDailyActiveUsers = totalUsers;
|
|
}
|
|
|
|
if (totalWeeklyActiveUsers > totalUsers) {
|
|
totalWeeklyActiveUsers = totalUsers;
|
|
}
|
|
|
|
if (totalMonthlyActiveUsers > totalUsers) {
|
|
totalMonthlyActiveUsers = totalUsers;
|
|
}
|
|
|
|
return {
|
|
...data,
|
|
totalUsers,
|
|
totalDailyActiveUsers,
|
|
totalWeeklyActiveUsers,
|
|
totalMonthlyActiveUsers,
|
|
};
|
|
},
|
|
});
|
|
}
|
|
|
|
async function unregister () {
|
|
return;
|
|
}
|
|
|
|
module.exports = {
|
|
register,
|
|
unregister,
|
|
};
|