Annotate

mod_webpresence/mod_webpresence.lua @ 5636:7e5701fbae88

mod_invites_api: add `module:depends("http");` to use `module:http_url()` in `prosodyctl`.
author Trần H. Trung <xmpp:trần.h.trung@trung.fun>
date Mon, 31 Jul 2023 11:52:00 +0700
parent 5633:758866b43aa4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
1 module:depends("adhoc");
643
28b0a8cd950a mod_webpresence: Update to timber, remove squish hack (icons are now loaded relative to the module file)
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
2 module:depends("http");
28b0a8cd950a mod_webpresence: Update to timber, remove squish hack (icons are now loaded relative to the module file)
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
3
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
4 local moduleHost = module.host;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
5 local moduleName = module:get_name();
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
6 local jid = require "util.jid";
4
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 local jid_split = require "util.jid".prepped_split;
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
8 local serialization = require "util.serialization";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
9
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
10 -- ADHOC
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
11 local storage = module:open_store(moduleName, "keyval");
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
12 local utilDataforms = require "util.dataforms";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
13 local utilAdhoc = require "util.adhoc";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
14 local adhoc_new = module:require("adhoc").new;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
15
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
16 local function webpresence_set(user, value)
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
17 local ok, err = storage:set(user, value); -- value is table.
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
18
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
19 if not ok or err then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
20 module:log(error, "Could not write data %s", tostring(user));
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
21 return ok, err;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
22 else
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
23 return ok;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
24 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
25 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
26 local function webpresence_get(user)
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
27 local result = storage:get(user);
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
28 if not result then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
29 result = { ["webpresence"] = false };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
30 webpresence_set(user, result);
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
31 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
32 return result[moduleName]; -- bool
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
33 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
34
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
35 local form = utilDataforms.new {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
36 title = "Web Presence Policy";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
37 instructions = "Your webpresence shows offline by default";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
38 {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
39 type = "boolean";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
40 name = moduleName;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
41 label = "Show";
5594
14480ca9576e mod_webpresence: Add TODO about fixing the first adhoc form.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5588
diff changeset
42 --value = webpresence_get();
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
43 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
44 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
45 local formResult = utilDataforms.new {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
46 title = "Web Presence Policy";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
47 {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
48 type = "boolean";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
49 name = moduleName;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
50 label = "Show";
5594
14480ca9576e mod_webpresence: Add TODO about fixing the first adhoc form.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5588
diff changeset
51 --value;
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
52 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
53 {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
54 type = "text-multi";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
55 name = "url";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
56 label = "Check your presence at";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
57 value = "text-multi\n";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
58 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
59 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
60
5633
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
61 local function webpresence_url(jid)
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
62 local path = "/status";
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
63 local config = module:get_option("http_paths");
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
64 if config then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
65 for k, v in pairs(config) do
5633
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
66 if k == moduleName then
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
67 path = v;
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
68 break;
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
69 end
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
70 end
5633
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
71 end
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
72
5633
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
73 local urlBase = module:context(module.host):http_url(module.name, path);
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
74 local style = { "text", "message", "json", "html" };
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
75 local urlResult = urlBase.."/"..jid.."\n";
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
76 for _, v in ipairs(style) do
5633
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
77 urlResult = urlResult..urlBase.."/"..jid.."/"..v.."\n";
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
78 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
79 return urlResult;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
80 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
81
5594
14480ca9576e mod_webpresence: Add TODO about fixing the first adhoc form.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5588
diff changeset
82 -- TODO:
14480ca9576e mod_webpresence: Add TODO about fixing the first adhoc form.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5588
diff changeset
83 -- Fix the handler (somehow) to make `form` shows the correct value.
14480ca9576e mod_webpresence: Add TODO about fixing the first adhoc form.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5588
diff changeset
84 --
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
85 local adhoc_handler = utilAdhoc.new_simple_form(form, function(fields, state, data)
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
86 local jid_bare = jid.bare(data.from);
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
87 local user, host = jid_split(jid_bare);
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
88
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
89 local oldData, _ = storage:get(user);
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
90 oldValue = webpresence_get(user);
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
91 form.webpresence = oldValue;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
92
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
93 local urlResult = webpresence_url(jid_bare);
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
94 local newValue = {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
95 [moduleName] = fields.webpresence;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
96 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
97
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
98 if state then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
99 return {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
100 status = "completed";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
101 info = "No change for: "..tostring(data.from).." …\n"
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
102 .."Old data: "..serialization.serialize(oldData).."\n"
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
103 .."New data: "..serialization.serialize(newValue).."\n";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
104 result = {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
105 layout = formResult;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
106 values = {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
107 webpresence = oldValue;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
108 url = urlResult;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
109 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
110 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
111 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
112 else
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
113 local resultSet, resultErr = webpresence_set(user, newValue)
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
114 if not resultSet or resultErr then
5633
758866b43aa4 mod_webpresence: use module:http_url() to get the correct url.
Trần H. Trung <xmpp:trần.h.trung@trung.fun>
parents: 5594
diff changeset
115 module:log("error", moduleName..": ".."Could not set value for "..user.."@"..host..": %s", errOut);
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
116 return {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
117 status = "completed";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
118 info = "Could not set value: "..tostring(data.from).." …\n"
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
119 .."Old data: "..serialization.serialize(oldData).."\n"
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
120 .."New data: "..serialization.serialize(newValue).."\n"
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
121 .."Error: "..errOut.."\n";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
122 result = {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
123 layout = formResult;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
124 values = {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
125 webpresence = newValue[moduleName];
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
126 url = urlResult;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
127 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
128 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
129 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
130 else
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
131 return {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
132 status = "completed";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
133 info = "Changing value for: "..tostring(data.from).." …\n"
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
134 .."Old data: "..serialization.serialize(oldData).."\n"
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
135 .."New data: "..serialization.serialize(newValue).."\n";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
136 result = {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
137 layout = formResult;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
138 values = {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
139 webpresence = newValue[moduleName];
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
140 url = urlResult;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
141 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
142 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
143 };
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
144 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
145 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
146 end);
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
147
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
148 module:provides("adhoc", adhoc_new("Web Presence Policy", moduleName, adhoc_handler, "any"));
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
149
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
150 -- HTTP
782
2d83708ea901 mod_webpresence: fixed text notation, added html, added status message output
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 779
diff changeset
151 local b64 = require "util.encodings".base64.encode;
2d83708ea901 mod_webpresence: fixed text notation, added html, added status message output
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 779
diff changeset
152 local sha1 = require "util.hashes".sha1;
1054
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
153 local stanza = require "util.stanza".stanza;
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
154 local json = require "util.json".encode_ordered;
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
155 local usermanager = require "core.usermanager";
4
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
156
779
36044b77b6c2 mod_webpresence: Added possibility to get status as text
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 643
diff changeset
157 local function require_resource(name)
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
158 local icon_path = module:get_option_string("webpresence_icons", "icons");
1054
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
159 local f, err = module:load_resource(icon_path.."/"..name);
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
160 if f then
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
161 return f:read("*a");
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
162 end
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
163 module:log("warn", "Failed to open image file %s", icon_path..name);
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
164 return "";
4
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
165 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166
779
36044b77b6c2 mod_webpresence: Added possibility to get status as text
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 643
diff changeset
167 local statuses = { online = {}, away = {}, xa = {}, dnd = {}, chat = {}, offline = {} };
4
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
169 local function user_list(host) return user:list(host); end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
170
643
28b0a8cd950a mod_webpresence: Update to timber, remove squish hack (icons are now loaded relative to the module file)
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
171 local function handle_request(event, path)
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
172 local status, message;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
173 local jid, type = path:match("([^/]+)/?(.*)$");
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
174 if jid then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
175 local user, host = jid_split(jid);
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
176 if host and not user then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
177 user, host = host, event.request.headers.host;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
178 if host then host = host:gsub(":%d+$", ""); end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
179 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
180 if host ~= moduleHost then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
181 status = "offline";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
182 else
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
183 if user and host and usermanager.user_exists(user, host) then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
184 local user_sessions = hosts[host] and hosts[host].sessions[user];
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
185 local show = webpresence_get(user)
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
186 if show == false then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
187 status = "offline";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
188 else
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
189 if user_sessions and user_sessions.top_resources then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
190 status = user_sessions.top_resources[1];
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
191 if status and status.presence then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
192 message = status.presence:child_with_name("status");
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
193 status = status.presence:child_with_name("show");
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
194 if not status then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
195 status = "online";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
196 else
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
197 status = status:get_text();
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
198 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
199 if message then
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
200 message = message:get_text();
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
201 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
202 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
203 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
204 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
205 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
206 end
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
207 status = status or "offline";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
208 end
1054
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
209
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
210 statuses[status].image = function()
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
211 return { status_code = 200, headers = { content_type = "image/png" },
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
212 body = require_resource("status_"..status..".png")
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
213 };
1054
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
214 end;
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
215 statuses[status].html = function()
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
216 local jid_hash = sha1(jid, true);
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
217 return { status_code = 200, headers = { content_type = "text/html" },
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
218 body = [[<!DOCTYPE html>]]..
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
219 tostring(
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
220 stanza("html")
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
221 :tag("head")
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
222 :tag("title"):text("XMPP Status Page for "..jid):up():up()
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
223 :tag("body")
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
224 :tag("div", { id = jid_hash.."_status", class = "xmpp_status" })
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
225 :tag("img", { id = jid_hash.."_img", class = "xmpp_status_image xmpp_status_"..status,
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
226 src = "data:image/png;base64,"..b64(require_resource("status_"..status..".png")) }):up()
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
227 :tag("span", { id = jid_hash.."_status_name", class = "xmpp_status_name" })
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
228 :text("\194\160"..status):up()
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
229 :tag("span", { id = jid_hash.."_status_message", class = "xmpp_status_message" })
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
230 :text(message and "\194\160"..message.."" or "")
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
231 )
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
232 };
1054
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
233 end;
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
234 statuses[status].text = function()
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
235 return { status_code = 200, headers = { content_type = "text/plain" },
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
236 body = status
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
237 };
1054
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
238 end;
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
239 statuses[status].message = function()
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
240 return { status_code = 200, headers = { content_type = "text/plain" },
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
241 body = (message and message or "")
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
242 };
1054
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
243 end;
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
244 statuses[status].json = function()
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
245 return { status_code = 200, headers = { content_type = "application/json" },
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
246 body = json({
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
247 jid = jid,
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
248 show = status,
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
249 status = (message and message or "null")
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
250 })
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
251 };
1054
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
252 end;
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
253 statuses[status].xml = function()
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
254 return { status_code = 200, headers = { content_type = "application/xml" },
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
255 body = [[<?xml version="1.0" encoding="utf-8"?>]]..
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
256 tostring(
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
257 stanza("result")
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
258 :tag("jid"):text(jid):up()
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
259 :tag("show"):text(status):up()
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
260 :tag("status"):text(message)
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
261 )
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
262 };
1054
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
263 end
1495
9a1b3f0d0939 mod_webpresence: fixed render-type handling (thanks to biszkopcik and Zash)
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1054
diff changeset
264
9a1b3f0d0939 mod_webpresence: fixed render-type handling (thanks to biszkopcik and Zash)
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1054
diff changeset
265 if ((type == "") or (not statuses[status][type])) then
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
266 type = "image"
1495
9a1b3f0d0939 mod_webpresence: fixed render-type handling (thanks to biszkopcik and Zash)
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1054
diff changeset
267 end;
9a1b3f0d0939 mod_webpresence: fixed render-type handling (thanks to biszkopcik and Zash)
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1054
diff changeset
268
1054
432dc4056114 mod_webpresence: added /xml and /json; Rewritten /html; A bit of refactoring;
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 847
diff changeset
269 return statuses[status][type]();
4
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
270 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
271
643
28b0a8cd950a mod_webpresence: Update to timber, remove squish hack (icons are now loaded relative to the module file)
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
272 module:provides("http", {
5588
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
273 default_path = "/status";
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
274 route = {
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
275 ["GET /*"] = handle_request;
f16720087ef2 mod_webpresence: Add opt-in mechanism.
Trần H. Trung <work@trung.fun>
parents: 2348
diff changeset
276 };
643
28b0a8cd950a mod_webpresence: Update to timber, remove squish hack (icons are now loaded relative to the module file)
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
277 });