comparison 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
comparison
equal deleted inserted replaced
3704:c6563625f60e 3705:5d3d8b75dee9
1 local json = require "util.json";
2 local array = require "util.array";
3
4 module:depends("http");
5
6 local total_users = 0;
7 for _ in require "core.usermanager".users(module.host) do
8 total_users = total_users + 1;
9 end
10
11 module:provides("http", {
12 default_path = "/.well-known/x-nodeinfo2";
13 route = {
14 GET = function (event)
15 event.response.headers.content_type = "application/json";
16 return json.encode({
17 version = "1.0";
18 server = {
19 baseUrl = module:http_url("","/");
20 name = module.host;
21 software = "Prosody";
22 version = prosody.version;
23 };
24 --[[
25 organization = {
26 name = "";
27 contact = "";
28 account = "";
29 };
30 --]]
31 protocols = array {
32 "xmpp",
33 };
34 --[[
35 services = {
36 inbound = array {
37 "irc";
38 };
39 outbound = array {
40 };
41 };
42 --]]
43 openRegistrations = module:get_option_boolean("allow_registration", false);
44 usage = {
45 users = {
46 total = total_users;
47 -- activeHalfyear = 1;
48 -- activeMonth = 1;
49 -- activeWeek = 1;
50 };
51 -- localPosts = 0;
52 -- localComments = 0;
53 };
54 });
55 end;
56 }
57 });
58