mod_nodeinfo2: Only expose amount of accounts if nodeinfo2_expose_users isn’t set to false
--- a/mod_nodeinfo2/README.markdown Mon Dec 30 22:43:01 2019 +0100
+++ b/mod_nodeinfo2/README.markdown Mon Dec 30 22:44:12 2019 +0100
@@ -22,6 +22,12 @@
}
```
+Set the `nodeinfo2_expose_users` option to false if you don’t want to expose
+statistics about the amount of users you host:
+```
+nodeinfo2_expose_users = false
+```
+
Set the `nodeinfo2_expose_posts` option to false if you don’t want to expose
statistics about the amount of messages being exchanged by your users:
```
--- a/mod_nodeinfo2/mod_nodeinfo2.lua Mon Dec 30 22:43:01 2019 +0100
+++ b/mod_nodeinfo2/mod_nodeinfo2.lua Mon Dec 30 22:44:12 2019 +0100
@@ -6,7 +6,11 @@
local os_time = os.time;
module:depends("http");
-module:depends("lastlog");
+
+local expose_users = module:get_option_boolean("nodeinfo2_expose_users", true);
+if expose_users then
+ module:depends("lastlog");
+end
local expose_posts = module:get_option_boolean("nodeinfo2_expose_posts", true);
if expose_posts then
@@ -52,21 +56,24 @@
end
end
-add_task(86400, update_user_list);
-update_user_list();
+if expose_users then
+ add_task(86400, update_user_list);
+ update_user_list();
+end
module:provides("http", {
default_path = "/.well-known/x-nodeinfo2";
route = {
GET = function (event)
- local usage = {
- users = {
+ local usage = {};
+ if expose_users then
+ usage.users = {
total = total_users;
activeWeek = week_users;
activeMonth = month_users;
activeHalfyear = half_year_users;
};
- };
+ end
if expose_posts then
local stats, changed_only, extras = get_stats();