Software /
code /
prosody
Comparison
plugins/mod_admin_adhoc.lua @ 11872:ffff0d8a9c68
mod_admin_adhoc: Move number coercion into util.dataforms
Internal use of XEP-0122 to shift the responsibility for converting
numbers to strings.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 25 Oct 2021 21:43:23 +0200 |
parent | 11727:f3aee8a825cc |
child | 12910:5c90862e39aa |
comparison
equal
deleted
inserted
replaced
11871:5dcbba569fb9 | 11872:ffff0d8a9c68 |
---|---|
252 }; | 252 }; |
253 | 253 |
254 local get_user_stats_result_layout = dataforms_new{ | 254 local get_user_stats_result_layout = dataforms_new{ |
255 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; | 255 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
256 { name = "ipaddresses", type = "text-multi", label = "IP Addresses" }; | 256 { name = "ipaddresses", type = "text-multi", label = "IP Addresses" }; |
257 { name = "rostersize", type = "text-single", label = "Roster size" }; | 257 { name = "rostersize", type = "text-single", label = "Roster size", datatype = "xs:integer" }; |
258 { name = "onlineresources", type = "text-multi", label = "Online Resources" }; | 258 { name = "onlineresources", type = "text-multi", label = "Online Resources" }; |
259 }; | 259 }; |
260 | 260 |
261 local get_user_stats_handler = adhoc_simple(get_user_stats_layout, function(fields, err) | 261 local get_user_stats_handler = adhoc_simple(get_user_stats_layout, function(fields, err) |
262 if err then | 262 if err then |
280 end | 280 end |
281 for resource, session in pairs((hosts[host].sessions[user] and hosts[host].sessions[user].sessions) or {}) do | 281 for resource, session in pairs((hosts[host].sessions[user] and hosts[host].sessions[user].sessions) or {}) do |
282 resources = resources .. "\n" .. resource; | 282 resources = resources .. "\n" .. resource; |
283 IPs = IPs .. "\n" .. session.ip; | 283 IPs = IPs .. "\n" .. session.ip; |
284 end | 284 end |
285 return { status = "completed", result = {layout = get_user_stats_result_layout, values = {ipaddresses = IPs, rostersize = tostring(rostersize), | 285 return { status = "completed", result = {layout = get_user_stats_result_layout, values = {ipaddresses = IPs, rostersize = rostersize, |
286 onlineresources = resources}} }; | 286 onlineresources = resources}} }; |
287 end); | 287 end); |
288 | 288 |
289 -- Getting a list of online users | 289 -- Getting a list of online users |
290 local get_online_users_layout = dataforms_new{ | 290 local get_online_users_layout = dataforms_new{ |
339 | 339 |
340 -- Getting a list of S2S connections (this host) | 340 -- Getting a list of S2S connections (this host) |
341 local list_s2s_this_result = dataforms_new { | 341 local list_s2s_this_result = dataforms_new { |
342 title = "List of S2S connections on this host"; | 342 title = "List of S2S connections on this host"; |
343 | 343 |
344 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/s2s#list" }; | 344 { name = "FORM_TYPE"; type = "hidden"; value = "http://prosody.im/protocol/s2s#list" }; |
345 { name = "sessions", type = "text-multi", label = "Connections:" }; | 345 { name = "sessions"; type = "text-multi"; label = "Connections:" }; |
346 { name = "num_in", type = "text-single", label = "#incoming connections:" }; | 346 { name = "num_in"; type = "text-single"; label = "#incoming connections:"; datatype = "xs:integer" }; |
347 { name = "num_out", type = "text-single", label = "#outgoing connections:" }; | 347 { name = "num_out"; type = "text-single"; label = "#outgoing connections:"; datatype = "xs:integer" }; |
348 }; | 348 }; |
349 | 349 |
350 local function session_flags(session, line) | 350 local function session_flags(session, line) |
351 line = line or {}; | 351 line = line or {}; |
352 | 352 |
421 s2s_list[i] = sess_lines[1]; | 421 s2s_list[i] = sess_lines[1]; |
422 end | 422 end |
423 | 423 |
424 return { status = "completed", result = { layout = list_s2s_this_result; values = { | 424 return { status = "completed", result = { layout = list_s2s_this_result; values = { |
425 sessions = t_concat(s2s_list, "\n"), | 425 sessions = t_concat(s2s_list, "\n"), |
426 num_in = tostring(count_in), | 426 num_in = count_in, |
427 num_out = tostring(count_out) | 427 num_out = count_out |
428 } } }; | 428 } } }; |
429 end | 429 end |
430 | 430 |
431 -- Getting a list of loaded modules | 431 -- Getting a list of loaded modules |
432 local list_modules_result = dataforms_new { | 432 local list_modules_result = dataforms_new { |