From 20543ca56ed6d66f98605f67bd41657e05bf74f8 Mon Sep 17 00:00:00 2001
From: Kim Alvefur <zash@zash.se>
Date: Mon, 25 Oct 2021 21:43:23 +0200
Subject: mod_admin_adhoc: Move number coercion into util.dataforms

Internal use of XEP-0122 to shift the responsibility for converting
numbers to strings.
---
 plugins/mod_admin_adhoc.lua | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/plugins/mod_admin_adhoc.lua b/plugins/mod_admin_adhoc.lua
index 1471fba0..d0b0d452 100644
--- a/plugins/mod_admin_adhoc.lua
+++ b/plugins/mod_admin_adhoc.lua
@@ -254,7 +254,7 @@ local get_user_stats_layout = dataforms_new{
 local get_user_stats_result_layout = dataforms_new{
 	{ name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" };
 	{ name = "ipaddresses", type = "text-multi", label = "IP Addresses" };
-	{ name = "rostersize", type = "text-single", label = "Roster size" };
+	{ name = "rostersize", type = "text-single", label = "Roster size", datatype = "xs:integer" };
 	{ name = "onlineresources", type = "text-multi", label = "Online Resources" };
 };
 
@@ -282,7 +282,7 @@ local get_user_stats_handler = adhoc_simple(get_user_stats_layout, function(fiel
 		resources = resources .. "\n" .. resource;
 		IPs = IPs .. "\n" .. session.ip;
 	end
-	return { status = "completed", result = {layout = get_user_stats_result_layout, values = {ipaddresses = IPs, rostersize = tostring(rostersize),
+	return { status = "completed", result = {layout = get_user_stats_result_layout, values = {ipaddresses = IPs, rostersize = rostersize,
 		onlineresources = resources}} };
 end);
 
@@ -341,10 +341,10 @@ end);
 local list_s2s_this_result = dataforms_new {
 	title = "List of S2S connections on this host";
 
-	{ name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/s2s#list" };
-	{ name = "sessions", type = "text-multi", label = "Connections:" };
-	{ name = "num_in", type = "text-single", label = "#incoming connections:" };
-	{ name = "num_out", type = "text-single", label = "#outgoing connections:" };
+	{ name = "FORM_TYPE"; type = "hidden"; value = "http://prosody.im/protocol/s2s#list" };
+	{ name = "sessions"; type = "text-multi"; label = "Connections:" };
+	{ name = "num_in"; type = "text-single"; label = "#incoming connections:"; datatype = "xs:integer" };
+	{ name = "num_out"; type = "text-single"; label = "#outgoing connections:"; datatype = "xs:integer" };
 };
 
 local function session_flags(session, line)
@@ -423,8 +423,8 @@ local function list_s2s_this_handler(self, data, state)
 
 	return { status = "completed", result = { layout = list_s2s_this_result; values = {
 		sessions = t_concat(s2s_list, "\n"),
-		num_in = tostring(count_in),
-		num_out = tostring(count_out)
+		num_in = count_in,
+		num_out = count_out
 	} } };
 end
 
-- 
cgit v1.2.3