Software /
code /
prosody-modules
Diff
mod_nodeinfo2/mod_nodeinfo2.lua @ 3792:aec772bbd558
mod_nodeinfo2: Only expose amount of accounts if nodeinfo2_expose_users isn’t set to false
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 30 Dec 2019 22:44:12 +0100 |
parent | 3791:34a8f9f996ec |
child | 4595:bac3dae031ee |
line wrap: on
line diff
--- 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();