Changeset

4455:89e54247ade6

mod_muc_http_defaults: Add template filters to let you extract room JID parts
author Kim Alvefur <zash@zash.se>
date Sun, 21 Feb 2021 16:15:21 +0100
parents 4454:8862a80cbd00
children 4456:8ed1989e99f9
files mod_muc_http_defaults/README.markdown mod_muc_http_defaults/mod_muc_http_defaults.lua
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_http_defaults/README.markdown	Mon Jan 25 08:41:37 2021 +0100
+++ b/mod_muc_http_defaults/README.markdown	Sun Feb 21 16:15:21 2021 +0100
@@ -21,6 +21,11 @@
 :   The value of the Authorization header to authenticate against the
     API. E.g. `"Bearer /rXU4tkQTYQMgdHfMLH6"`{.lua}
 
+In the URL template variable, the room JID is available as `{room.jid}`,
+which would be turned into `room@muc.host`. To only get the room
+localpart, `{room.jid|jid_node}` can be used, and `{room.jid|jid_host}`
+splits out the `muc.host` part.
+
 ## Example
 
 ``` {.lua}
--- a/mod_muc_http_defaults/mod_muc_http_defaults.lua	Mon Jan 25 08:41:37 2021 +0100
+++ b/mod_muc_http_defaults/mod_muc_http_defaults.lua	Sun Feb 21 16:15:21 2021 +0100
@@ -11,7 +11,8 @@
 local json = require "util.json";
 local st = require "util.stanza";
 
-local render = require "util.interpolation".new("%b{}", uh.urlencode);
+local funcs = {jid_bare = jid.bare; jid_host = jid.host; jid_node = jid.node};
+local render = require"util.interpolation".new("%b{}", uh.urlencode, funcs);
 
 module:depends"muc";