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