Mercurial > prosody-modules
view mod_nodeinfo2/mod_nodeinfo2.lua @ 3705:5d3d8b75dee9
mod_nodeinfo2: Expose service metadata per NodeInfo2
https://git.feneas.org/jaywink/nodeinfo2
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 25 Jun 2019 09:05:59 +0200 |
parents | |
children | 36b645e94325 |
line wrap: on
line source
local json = require "util.json"; local array = require "util.array"; module:depends("http"); local total_users = 0; for _ in require "core.usermanager".users(module.host) do total_users = total_users + 1; end module:provides("http", { default_path = "/.well-known/x-nodeinfo2"; route = { GET = function (event) event.response.headers.content_type = "application/json"; return json.encode({ version = "1.0"; server = { baseUrl = module:http_url("","/"); name = module.host; software = "Prosody"; version = prosody.version; }; --[[ organization = { name = ""; contact = ""; account = ""; }; --]] protocols = array { "xmpp", }; --[[ services = { inbound = array { "irc"; }; outbound = array { }; }; --]] openRegistrations = module:get_option_boolean("allow_registration", false); usage = { users = { total = total_users; -- activeHalfyear = 1; -- activeMonth = 1; -- activeWeek = 1; }; -- localPosts = 0; -- localComments = 0; }; }); end; } });