Software /
code /
prosody-modules
Changeset
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 |
parents | 3791:34a8f9f996ec |
children | 3793:0d3926e49b55 |
files | mod_nodeinfo2/README.markdown mod_nodeinfo2/mod_nodeinfo2.lua |
diffstat | 2 files changed, 19 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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();