# HG changeset patch # User Kim Alvefur # Date 1561446359 -7200 # Node ID 5d3d8b75dee9c497abf9e1de195c1ba76d88b6fe # Parent c6563625f60e4ad9854fa5d6558c3e73c4dfe636 mod_nodeinfo2: Expose service metadata per NodeInfo2 https://git.feneas.org/jaywink/nodeinfo2 diff -r c6563625f60e -r 5d3d8b75dee9 mod_nodeinfo2/mod_nodeinfo2.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_nodeinfo2/mod_nodeinfo2.lua Tue Jun 25 09:05:59 2019 +0200 @@ -0,0 +1,58 @@ +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; + } +}); +