Mercurial > prosody-modules
comparison 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 |
| parents | 34a8f9f996ec |
| children | bac3dae031ee |
comparison
equal
deleted
inserted
replaced
| 3791:34a8f9f996ec | 3792:aec772bbd558 |
|---|---|
| 4 local get_stats = require "core.statsmanager".get_stats; | 4 local get_stats = require "core.statsmanager".get_stats; |
| 5 local list_users = require "core.usermanager".users; | 5 local list_users = require "core.usermanager".users; |
| 6 local os_time = os.time; | 6 local os_time = os.time; |
| 7 | 7 |
| 8 module:depends("http"); | 8 module:depends("http"); |
| 9 module:depends("lastlog"); | 9 |
| 10 local expose_users = module:get_option_boolean("nodeinfo2_expose_users", true); | |
| 11 if expose_users then | |
| 12 module:depends("lastlog"); | |
| 13 end | |
| 10 | 14 |
| 11 local expose_posts = module:get_option_boolean("nodeinfo2_expose_posts", true); | 15 local expose_posts = module:get_option_boolean("nodeinfo2_expose_posts", true); |
| 12 if expose_posts then | 16 if expose_posts then |
| 13 module:depends("measure_message_e2ee"); | 17 module:depends("measure_message_e2ee"); |
| 14 end | 18 end |
| 50 month_users = nil; | 54 month_users = nil; |
| 51 half_year_users = nil; | 55 half_year_users = nil; |
| 52 end | 56 end |
| 53 end | 57 end |
| 54 | 58 |
| 55 add_task(86400, update_user_list); | 59 if expose_users then |
| 56 update_user_list(); | 60 add_task(86400, update_user_list); |
| 61 update_user_list(); | |
| 62 end | |
| 57 | 63 |
| 58 module:provides("http", { | 64 module:provides("http", { |
| 59 default_path = "/.well-known/x-nodeinfo2"; | 65 default_path = "/.well-known/x-nodeinfo2"; |
| 60 route = { | 66 route = { |
| 61 GET = function (event) | 67 GET = function (event) |
| 62 local usage = { | 68 local usage = {}; |
| 63 users = { | 69 if expose_users then |
| 70 usage.users = { | |
| 64 total = total_users; | 71 total = total_users; |
| 65 activeWeek = week_users; | 72 activeWeek = week_users; |
| 66 activeMonth = month_users; | 73 activeMonth = month_users; |
| 67 activeHalfyear = half_year_users; | 74 activeHalfyear = half_year_users; |
| 68 }; | 75 }; |
| 69 }; | 76 end |
| 70 | 77 |
| 71 if expose_posts then | 78 if expose_posts then |
| 72 local stats, changed_only, extras = get_stats(); | 79 local stats, changed_only, extras = get_stats(); |
| 73 for stat, _ in pairs(stats) do | 80 for stat, _ in pairs(stats) do |
| 74 if stat == "/"..module.host.."/mod_measure_message_e2ee/message:rate" then | 81 if stat == "/"..module.host.."/mod_measure_message_e2ee/message:rate" then |
