Mercurial > prosody-modules
view mod_stats39/mod_stats39.lua @ 4523:6e20e6bf96f0
mod_rest: Add XEP-0066 to mapping schema (breaking from previous jsonmap)
before:
oob_url: http://example.com/
after:
oob:
url: http://example.com/
desc: optional description
Deals with the fact that the name and namespace differs based on whether
it's in an iq or message stanza, unlike oob_url
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 22 Mar 2021 23:14:25 +0100 |
parents | ffc64d285a96 |
children | bac3dae031ee |
line wrap: on
line source
local statsman = require "core.statsmanager"; local st = require "util.stanza"; local s_format = string.format; module:add_feature("http://jabber.org/protocol/stats"); module:hook("iq/host/http://jabber.org/protocol/stats:query", function (event) local origin, stanza = event.origin, event.stanza; local stats, _, extra = statsman.get_stats(); local reply = st.reply(stanza); reply:tag("query", { xmlns = "http://jabber.org/protocol/stats" }); for stat, value in pairs(stats) do local unit = extra[stat] and extra[stat].units; reply:tag("stat", { name = stat, unit = unit, value = s_format("%.12g", value) }):up(); end origin.send(reply); return true; end)