# HG changeset patch # User Emmanuel Gil Peyrot # Date 1577742252 -3600 # Node ID aec772bbd558328f4f7115ce01927410db8998e4 # Parent 34a8f9f996ec853ebecc242df238d3c7e8db835d mod_nodeinfo2: Only expose amount of accounts if nodeinfo2_expose_users isn’t set to false diff -r 34a8f9f996ec -r aec772bbd558 mod_nodeinfo2/README.markdown --- 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: ``` diff -r 34a8f9f996ec -r aec772bbd558 mod_nodeinfo2/mod_nodeinfo2.lua --- 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();