annotate mod_conversejs/README.md @ 6299:5cf5ee23b361

mod_voipms: New Module to send and receive SMS/MMS via VoIP.ms APIs. diff --git a/mod_voipms/README.md b/mod_voipms/README.md new file mode 100644 --- /dev/null +++ b/mod_voipms/README.md @@ -0,0 +1,51 @@ +--- +labels: +- 'Stage-Alpha' +- 'Type-Web' +summary: Send and receive SMS/MMS via VoIP.ms APIs. +rockspec: + build: + modules: + mod_voipms: mod_voipms.lua +... + +Introduction +============ + +This is a Prosody module to map JIDs to DIDs on VoIP.ms and support sending/receiving SMS/MMS. + +Configuration +============= + +| option | type | default | +|-----------------------|--------|---------| +| voipms\_api\_username | string | nil | +| voipms\_api\_password | string | nil | +| voipms\_query\_key | string | nil | +| voipms\_jid\_map | table | nil | +``` +VirtualHost "sms.example.com" +modules_enabled = { + "voipms"; +} +voipms_api_username = john@example.com -- E-mail registered with VoIP.ms +voipms_api_password = abcd1234 -- API password configured in VoIP.ms +voipms_query_key = some_query_key -- query param 'key' part of your URL callback +voipms_jid_map = { + ["your_jid@your_domain.com"] = "+1234567890" +} +``` + +HTTP +==== + +The module is served on Prosody's default HTTP ports at the path /voipms. More details on configuring HTTP modules in Prosody can be found in the HTTP documentation. + +VoIP.ms Webhook URL +=================== + +This module receives the VoIP.ms Webhook URL (POST) at the /voipms endpoint. It uses the sendSMS/sendMMS GET methods against the VoIP.ms APIs. This is an example webhook to use in VoIP.ms: + +``` +https://sms.example.com/voipms?key=some_query_key +``` diff --git a/mod_voipms/mod_voipms.lua b/mod_voipms/mod_voipms.lua new file mode 100644 --- /dev/null +++ b/mod_voipms/mod_voipms.lua @@ -0,0 +1,166 @@ +local http = require "net.http" +local json = require "util.json" +local st = require "util.stanza" + +local api_username = module:get_option_string("voipms_api_username") +local api_password = module:get_option_string("voipms_api_password") +local query_key = module:get_option("voipms_query_key") +local jid_map = module:get_option("voipms_jid_map") or {} +local rest_endpoint = "https://voip.ms/api/v1/rest.php" + +if not api_username or not api_password or not query_key then + module:log("error", "Missing required config values (voipms_api_username, voipms_api_password, voipms_query_key)") + return +end + +module:depends("http") + +local function normalize_number(num) + if not num then return nil end + if num:sub(1, 1) ~= "+" then + return "+1" .. num + end + return num +end + +local function extract_query_key(event) + return (event.request.url.query or ""):match("key=([^&]+)") +end + +module:provides("http", { + route = { + ["POST"] = function(event) + local req = event.request + local body = req.body or "" + + if extract_query_key(event) ~= query_key then + module:log("warn", "Unauthorized webhook: missing or invalid key") + return { status_code = 403 } + end + + local json_payload, err = json.decode(body) + if not json_payload then + module:log("warn", "Invalid JSON: %s", err or "unknown error") + return { status_code = 400 } + end + + local payload = json_payload.data and json_payload.data.payload + if not payload then + module:log("warn", "Missing payload in JSON") + return { status_code = 400 } + end + + local from = payload.from and payload.from.phone_number + local to_list = payload.to or {} + local to = #to_list > 0 and to_list[1].phone_number or nil + + if not from or not to then + module:log("warn", "Missing phone numbers (from: %s, to: %s)", tostring(from), tostring(to)) + return { status_code = 400 } + end + + local normalized_to = normalize_number(to) + local target_jid = nil + + for jid, did in pairs(jid_map) do + if normalize_number(did) == normalized_to then + target_jid = jid + break + end + end + + if not target_jid then + module:log("warn", "No JID mapping for DID %s", normalized_to) + return { status_code = 404 } + end + + local normalized_from = normalize_number(from) + local message_text = payload.text or "" + + local message = st.message({ + from = normalized_from .. "@" .. module.host, + to = target_jid, + type = "chat" + }):tag("body"):text(message_text):up() + + if payload.media and #payload.media > 0 then + for _, media_item in ipairs(payload.media) do + if media_item.url then + message_text = message_text .. "\n" .. media_item.url + message:tag("x", { xmlns = "jabber:x:oob" }) + :tag("url"):text(media_item.url):up():up() + end + end + end + + module:send(message) + module:log("info", "Delivered SMS from %s to %s", normalized_from, target_jid) + + return { status_code = 204 } + end + } +}) + +module:hook("message/bare", function(event) + local stanza = event.stanza + if stanza.attr.type ~= "chat" then return end + + local from_jid = stanza.attr.from + local to_jid = stanza.attr.to + local body = stanza:get_child_text("body") + if not body or body == "" then return end + + local from_number = jid_map[from_jid] + if not from_number then + module:log("warn", "No DID mapping for JID %s", from_jid) + return + end + + local to_number = to_jid:match("^([^@]+)") + if not to_number then + module:log("warn", "Malformed JID in message.to: %s", to_jid) + return + end + + to_number = normalize_number(to_number) + + local media_urls = {} + for line in body:gmatch("[^\r\n]+") do + if line:match("^https?://") then + table.insert(media_urls, line) + end + end + + local method = (#media_urls > 0) and "sendMMS" or "sendSMS" + local query = { + api_username = api_username, + api_password = api_password, + method = method, + did = from_number, + dst = to_number, + message = body + } + + if method == "sendMMS" then + for i, url in ipairs(media_urls) do + query["media_url[" .. (i - 1) .. "]"] = url + end + end + + local query_str = http.formencode(query) + + http.request(rest_endpoint .. "?" .. query_str, { + method = "GET"; + }, function(response_body, code) + if code == 200 then + local resp, err = json.decode(response_body) + if not resp or resp.status ~= "success" then + module:log("error", "Failed to send %s: %s", method, err or (resp and resp.status) or "unknown") + else + module:log("info", "Sent %s from %s to %s", method, from_number, to_number) + end + else + module:log("error", "HTTP error sending %s: code %s", method, tostring(code)) + end + end) +end)
author Chaz <menel@snikket.de>
date Mon, 21 Jul 2025 23:57:37 +0200
parents fe081789f7b5
children 2511bf07b8d2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2878
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 ---
4606
d6eb2b722b90 mod_conversejs: Update description
Kim Alvefur <zash@zash.se>
parents: 4208
diff changeset
2 summary: Simplify setup of Converse.js
2878
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 depends:
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 - 'mod\_bosh'
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 - 'mod\_websocket'
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 provides:
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 - http
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 title: 'mod\_conversejs'
4166
7678b4880719 mod_conversejs: Hint that templates should be copied into packages
Kim Alvefur <zash@zash.se>
parents: 4147
diff changeset
9 rockspec:
7678b4880719 mod_conversejs: Hint that templates should be copied into packages
Kim Alvefur <zash@zash.se>
parents: 4147
diff changeset
10 build:
7678b4880719 mod_conversejs: Hint that templates should be copied into packages
Kim Alvefur <zash@zash.se>
parents: 4147
diff changeset
11 copy_directories:
7678b4880719 mod_conversejs: Hint that templates should be copied into packages
Kim Alvefur <zash@zash.se>
parents: 4147
diff changeset
12 - templates
2878
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 ---
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 Introduction
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 ============
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17
4606
d6eb2b722b90 mod_conversejs: Update description
Kim Alvefur <zash@zash.se>
parents: 4208
diff changeset
18 This module simplifies setup of [Converse.js](https://conversejs.org/)
d6eb2b722b90 mod_conversejs: Update description
Kim Alvefur <zash@zash.se>
parents: 4208
diff changeset
19 by serving it from Prosodys internal [http server][doc:http] along with
d6eb2b722b90 mod_conversejs: Update description
Kim Alvefur <zash@zash.se>
parents: 4208
diff changeset
20 generated configuration to match the local VirtualHost. It becomes
d6eb2b722b90 mod_conversejs: Update description
Kim Alvefur <zash@zash.se>
parents: 4208
diff changeset
21 available on an URL like `https://example.com:5281/conversejs`
3958
cacd753848b2 mod_conversejs/README: Add an example of the URL to open
Kim Alvefur <zash@zash.se>
parents: 3711
diff changeset
22
2878
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 Configuration
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 =============
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25
2918
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
26 The module uses general Prosody options for basic configuration. It
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
27 should just work after loading it.
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
28
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
29 ``` {.lua}
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
30 modules_enabled = {
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
31 -- other modules...
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
32 "conversejs";
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
33 }
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
34 ```
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
35
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
36 Authentication
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
37 --------------
2878
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38
2918
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
39 [Authentication settings][doc:authentication] are used determine
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
40 whether to configure Converse.js to use `login` or `anonymous` mode.
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
41
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
42 Connection methods
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
43 ------------------
2878
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
44
4206
432e948cd50e mod_conversejs: Tweak wording
Kim Alvefur <zash@zash.se>
parents: 4166
diff changeset
45 mod_conversejs also determines the [BOSH][doc:setting_up_bosh] and
3362
af085e8b9d48 mod_conversejs: Link to BOSH and WebSockets setup instructions instead of module pages
Kim Alvefur <zash@zash.se>
parents: 3334
diff changeset
46 [WebSocket][doc:websocket] URL automatically, see their respective
af085e8b9d48 mod_conversejs: Link to BOSH and WebSockets setup instructions instead of module pages
Kim Alvefur <zash@zash.se>
parents: 3334
diff changeset
47 documentation for how to configure them. Both connection methods are
af085e8b9d48 mod_conversejs: Link to BOSH and WebSockets setup instructions instead of module pages
Kim Alvefur <zash@zash.se>
parents: 3334
diff changeset
48 loaded automatically.
2918
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
49
4207
e8fbc0773141 mod_conversejs/README: Add text about preventing auto-load of mod_bosh/ws
Kim Alvefur <zash@zash.se>
parents: 4206
diff changeset
50 Auto-loading of `mod_bosh` or `mod_websocket` can be prevented by adding
e8fbc0773141 mod_conversejs/README: Add text about preventing auto-load of mod_bosh/ws
Kim Alvefur <zash@zash.se>
parents: 4206
diff changeset
51 it to `modules_disabled` but note that at least one of them must be
e8fbc0773141 mod_conversejs/README: Add text about preventing auto-load of mod_bosh/ws
Kim Alvefur <zash@zash.se>
parents: 4206
diff changeset
52 allowed for Converse.js to work.
e8fbc0773141 mod_conversejs/README: Add text about preventing auto-load of mod_bosh/ws
Kim Alvefur <zash@zash.se>
parents: 4206
diff changeset
53
2918
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
54 HTTP
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
55 ----
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
56
3304
27db90321e7b Fix README of mod_conversejs
t2d <td@tem.li>
parents: 2920
diff changeset
57 The module is served on Prosody's default HTTP ports at the path
27db90321e7b Fix README of mod_conversejs
t2d <td@tem.li>
parents: 2920
diff changeset
58 `/conversejs`. More details on configuring HTTP modules in Prosody can
27db90321e7b Fix README of mod_conversejs
t2d <td@tem.li>
parents: 2920
diff changeset
59 be found in our [HTTP documentation](http://prosody.im/doc/http).
2878
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
60
3598
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
61 ## Templates
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
62
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
63 The HTML and JS can be customized either by editing the included
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
64 `template.html` and `template.js` files or configuring your own like:
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
65
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
66 ```lua
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
67 conversejs_html_template = "/path/to/my-template.html"
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
68 conversejs_js_template = "/path/to/my-template.js"
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
69 ```
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
70
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
71 The HTML template uses Prosodys
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
72 [`util.interpolation`][doc:developers:util:interpolation] template
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
73 library while the JS template has `%s` where generated settings are
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
74 injected.
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
75
2919
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
76 Other
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
77 -----
2878
ed5ad4fd5bdd mod_conversejs: Add a readme
Kim Alvefur <zash@zash.se>
parents:
diff changeset
78
2919
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
79 To pass [other Converse.js
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
80 options](https://conversejs.org/docs/html/configuration.html), or
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
81 override the derived settings, one can set `conversejs_options` like
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
82 this:
2918
d2d0715f30d9 mod_conversejs/README: Expand config section
Kim Alvefur <zash@zash.se>
parents: 2878
diff changeset
83
2919
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
84 ``` {.lua}
3304
27db90321e7b Fix README of mod_conversejs
t2d <td@tem.li>
parents: 2920
diff changeset
85 conversejs_options = {
2919
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
86 debug = true;
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
87 view_mode = "fullscreen";
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
88 }
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
89 ```
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
90
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
91 Note that the following options are automatically provided, and
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
92 **overriding them may cause problems**:
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
93
3334
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
94 - `authentication` *based on Prosody's authentication settings*
2919
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
95 - `bosh_service_url`
3495
5567098a7f91 mod_conversejs/README: Update text about mod_bosh and mod_websocket
Kim Alvefur <zash@zash.se>
parents: 3362
diff changeset
96 - `websocket_url`
4208
b74d6a3f0c3f mod_conversejs/README: Complete list of auto-injected settings
Kim Alvefur <zash@zash.se>
parents: 4207
diff changeset
97 - `discover_connection_methods` *Disabled since we provide this*
b74d6a3f0c3f mod_conversejs/README: Complete list of auto-injected settings
Kim Alvefur <zash@zash.se>
parents: 4207
diff changeset
98 - `assets_path`
b74d6a3f0c3f mod_conversejs/README: Complete list of auto-injected settings
Kim Alvefur <zash@zash.se>
parents: 4207
diff changeset
99 - `allow_registration` *based on whether registration is enabled*
b74d6a3f0c3f mod_conversejs/README: Complete list of auto-injected settings
Kim Alvefur <zash@zash.se>
parents: 4207
diff changeset
100 - These settings are set to the current `VirtualHost`:
b74d6a3f0c3f mod_conversejs/README: Complete list of auto-injected settings
Kim Alvefur <zash@zash.se>
parents: 4207
diff changeset
101 - `jid`
b74d6a3f0c3f mod_conversejs/README: Complete list of auto-injected settings
Kim Alvefur <zash@zash.se>
parents: 4207
diff changeset
102 - `default_domain`
b74d6a3f0c3f mod_conversejs/README: Complete list of auto-injected settings
Kim Alvefur <zash@zash.se>
parents: 4207
diff changeset
103 - `domain_placeholder`
b74d6a3f0c3f mod_conversejs/README: Complete list of auto-injected settings
Kim Alvefur <zash@zash.se>
parents: 4207
diff changeset
104 - `registration_domain`
3495
5567098a7f91 mod_conversejs/README: Update text about mod_bosh and mod_websocket
Kim Alvefur <zash@zash.se>
parents: 3362
diff changeset
105
5567098a7f91 mod_conversejs/README: Update text about mod_bosh and mod_websocket
Kim Alvefur <zash@zash.se>
parents: 3362
diff changeset
106 `mod_bosh` and/or `mod_websocket` are automatically enabled if available
5567098a7f91 mod_conversejs/README: Update text about mod_bosh and mod_websocket
Kim Alvefur <zash@zash.se>
parents: 3362
diff changeset
107 and the respective endpoint is included in the generated options.
2919
0ea93da47db9 mod_conversejs: Allow passing arbitrary options trough to Converse.js
Kim Alvefur <zash@zash.se>
parents: 2918
diff changeset
108
4147
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
109 ## Loading resources
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
110
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
111 By default the module will load the main script and CSS from
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
112 cdn.conversejs.org. For privacy or performance reasons you may want to
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
113 load the scripts from somewhere else.
3334
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
114
4147
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
115 To use a local distribution or build of Converse.js set
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
116 conversejs_resources to the local path of "dist" directory:
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
117
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
118 ``` {.lua}
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
119 conversejs_resources = "/usr/src/conversejs/dist";
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
120 ```
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
121
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
122 To use a different web server or CDN simply use the conversejs_cdn
3a06dea21ea1 mod_conversejs: Enable serving resources from built-in http server
Kim Alvefur <zash@zash.se>
parents: 3958
diff changeset
123 option:
3334
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
124
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
125 ``` {.lua}
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
126 conversejs_cdn = "https://cdn.example.com"
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
127 ```
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
128
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
129 To select a specific version of Converse.js, you may override the version:
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
130
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
131 ``` {.lua}
3643
740870196b97 mod_http_stats_stream: Make global to simplify
Kim Alvefur <zash@zash.se>
parents: 3598
diff changeset
132 conversejs_version = "5.0.0"
3334
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
133 ```
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
134
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
135 Note that versions other than the default may not have been tested with this module, and may include incompatible changes.
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
136
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
137 Finally, if you can override all of the above and just specify links directly to the CSS and JS files:
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
138
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
139 ``` {.lua}
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
140 conversejs_script = "https://example.com/my-converse.js"
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
141 conversejs_css = "https://example.com/my-converse.css"
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
142 ```
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
143
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
144 Additional tags
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
145 ---------------
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
146
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
147 To add additional tags to the module, such as custom CSS or scripts, you may use the conversejs_tags option:
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
148
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
149 ``` {.lua}
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
150 conversejs_tags = {
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
151 -- Load custom CSS
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
152 [[<link rel="stylesheet" href="https://example.org/css/custom.css">]];
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
153
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
154 -- Load libsignal-protocol.js for OMEMO support (GPLv3; be aware of licence implications)
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
155 [[<script src="https://cdn.conversejs.org/3rdparty/libsignal-protocol.min.js"></script>]];
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
156 }
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
157 ```
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
158
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
159 The example above uses the `[[` and `]]` syntax simply because it will not conflict with any embedded quotes.
04e5e34893e1 mod_conversejs: Update README
Matthew Wild <mwild1@gmail.com>
parents: 3311
diff changeset
160
5871
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
161 Custimizing the generated PWA options
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
162 -------------------------------------
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
163
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
164 ``` {.lua}
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
165 conversejs_name = "Service name" -- Also used as the web page title
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
166 conversejs_short_name = "Shorter name"
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
167 conversejs_description = "Description of the service"
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
168 conversejs_manifest_icons = {
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
169 {
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
170 src = "https://example.com/logo/512.png",
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
171 sizes = "512x512",
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
172 },
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
173 {
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
174 src = "https://example.com/logo/192.png",
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
175 sizes = "192x192",
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
176 },
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
177 {
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
178 src = "https://example.com/logo/192.svg",
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
179 sizes = "192x192",
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
180 },
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
181 {
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
182 src = "https://example.com/logo/512.svg",
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
183 sizes = "512x512",
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
184 },
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
185 }
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
186 conversejs_pwa_color = "#397491"
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
187 ```
1c8197075d04 mod_conversejs: Allow installation as PWA
BetaRays <BetaRays@proton.me>
parents: 4913
diff changeset
188
2920
4d03ac2737ab mod_conversejs/README: Add compatibility section
Kim Alvefur <zash@zash.se>
parents: 2919
diff changeset
189 Compatibility
4d03ac2737ab mod_conversejs/README: Add compatibility section
Kim Alvefur <zash@zash.se>
parents: 2919
diff changeset
190 =============
4d03ac2737ab mod_conversejs/README: Add compatibility section
Kim Alvefur <zash@zash.se>
parents: 2919
diff changeset
191
3598
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
192 Prosody version state
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
193 ----------------- ---------------
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
194 0.9 Does not work
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
195 0.10 Should work
3711
309fa523c424 mod_conversejs: Update compatibility section, pretty sure it works with 0.11
Kim Alvefur <zash@zash.se>
parents: 3643
diff changeset
196 0.11 Works
3598
1921ae4449b8 mod_conversejs: Separate out templates into separate configurable files (breaks 0.9 compat)
Kim Alvefur <zash@zash.se>
parents: 3495
diff changeset
197 trunk Works