Initial commit.

- Only modifies the total*User values of /api/v1/server/stats.
This commit is contained in:
2023-12-21 13:54:23 +09:00
commit 66ae7583d2
6 changed files with 103 additions and 0 deletions

56
main.js Normal file
View File

@@ -0,0 +1,56 @@
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,
};