You've already forked peertube-plugin-hide-root-user
Adjust totalModerators and totalAdmins too
This commit is contained in:
35
main.js
35
main.js
@@ -1,14 +1,6 @@
|
||||
async function register ({
|
||||
registerHook,
|
||||
registerSetting,
|
||||
settingsManager,
|
||||
storageManager,
|
||||
videoCategoryManager,
|
||||
videoLicenceManager,
|
||||
videoLanguageManager,
|
||||
}) {
|
||||
async function register({ registerHook }) {
|
||||
registerHook({
|
||||
target: 'filter:api.server.stats.get.result',
|
||||
target: "filter:api.server.stats.get.result",
|
||||
handler: (data) => {
|
||||
if (!data) return {};
|
||||
|
||||
@@ -17,26 +9,47 @@ async function register ({
|
||||
totalDailyActiveUsers,
|
||||
totalWeeklyActiveUsers,
|
||||
totalMonthlyActiveUsers,
|
||||
totalModerators,
|
||||
totalAdmins,
|
||||
} = data;
|
||||
|
||||
// Remove one from total users if there are more than one
|
||||
if (totalUsers > 1) {
|
||||
totalUsers = totalUsers - 1;
|
||||
}
|
||||
|
||||
// Remove one from the moderator count if there are more than one
|
||||
if (totalModerators > 1) {
|
||||
totalModerators = totalModerators - 1;
|
||||
}
|
||||
|
||||
// Remove one from the admin count if there are more than one
|
||||
if (totalAdmins > 1) {
|
||||
totalAdmins = totalAdmins - 1;
|
||||
}
|
||||
|
||||
// Adjust daily active user count if there are more listed than there
|
||||
// are total users.
|
||||
if (totalDailyActiveUsers > totalUsers) {
|
||||
totalDailyActiveUsers = totalUsers;
|
||||
}
|
||||
|
||||
// Adjust weekly active user count if there are more listed than there
|
||||
// are total users.
|
||||
if (totalWeeklyActiveUsers > totalUsers) {
|
||||
totalWeeklyActiveUsers = totalUsers;
|
||||
}
|
||||
|
||||
// Adjust monthly active user count if there are more listed than there
|
||||
// are total users.
|
||||
if (totalMonthlyActiveUsers > totalUsers) {
|
||||
totalMonthlyActiveUsers = totalUsers;
|
||||
}
|
||||
|
||||
return {
|
||||
...data,
|
||||
totalAdmins,
|
||||
totalModerators,
|
||||
totalUsers,
|
||||
totalDailyActiveUsers,
|
||||
totalWeeklyActiveUsers,
|
||||
@@ -46,7 +59,7 @@ async function register ({
|
||||
});
|
||||
}
|
||||
|
||||
async function unregister () {
|
||||
async function unregister() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user