Comparison

util/rsm.lua @ 10761:b53193bb21cc

util.rsm: Fix passing number as attribute
author Kim Alvefur <zash@zash.se>
date Thu, 23 Apr 2020 18:16:36 +0200
parent 7852:e594010e1ba0
child 10763:e0e2ae050d65
comparison
equal deleted inserted replaced
10760:c9d1d9c80e1e 10761:b53193bb21cc
9 -- XEP-0313: Message Archive Management for Prosody 9 -- XEP-0313: Message Archive Management for Prosody
10 -- 10 --
11 11
12 local stanza = require"util.stanza".stanza; 12 local stanza = require"util.stanza".stanza;
13 local tostring, tonumber = tostring, tonumber; 13 local tostring, tonumber = tostring, tonumber;
14 local s_format = string.format;
14 local type = type; 15 local type = type;
15 local pairs = pairs; 16 local pairs = pairs;
17
18 local function inttostr(n)
19 return s_format("%d", n);
20 end
16 21
17 local xmlns_rsm = 'http://jabber.org/protocol/rsm'; 22 local xmlns_rsm = 'http://jabber.org/protocol/rsm';
18 23
19 local element_parsers = {}; 24 local element_parsers = {};
20 25
43 end 48 end
44 49
45 local element_generators = setmetatable({ 50 local element_generators = setmetatable({
46 first = function(st, data) 51 first = function(st, data)
47 if type(data) == "table" then 52 if type(data) == "table" then
48 st:tag("first", { index = data.index }):text(data[1]):up(); 53 st:tag("first", { index = inttostr(data.index) }):text(data[1]):up();
49 else 54 else
50 st:tag("first"):text(tostring(data)):up(); 55 st:tag("first"):text(tostring(data)):up();
51 end 56 end
52 end; 57 end;
53 before = function(st, data) 58 before = function(st, data)