Comparison

plugins/muc/history.lib.lua @ 10355:cb9755d7a36e

MUC: Advertise history related fields as integers via XEP-0122 This takes advantage of data type validation and conversion done in util.dataforms.
author Kim Alvefur <zash@zash.se>
date Sun, 20 Oct 2019 23:47:48 +0200
parent 10230:dd7e924c74ef
child 10775:1641e33f1d36
comparison
equal deleted inserted replaced
10354:8a186801257b 10355:cb9755d7a36e
46 46
47 module:hook("muc-config-form", function(event) 47 module:hook("muc-config-form", function(event)
48 table.insert(event.form, { 48 table.insert(event.form, {
49 name = "muc#roomconfig_historylength"; 49 name = "muc#roomconfig_historylength";
50 type = "text-single"; 50 type = "text-single";
51 datatype = "xs:integer";
51 label = "Maximum number of history messages returned by room"; 52 label = "Maximum number of history messages returned by room";
52 desc = "Specify the maximum number of previous messages that should be sent to users when they join the room"; 53 desc = "Specify the maximum number of previous messages that should be sent to users when they join the room";
53 value = tostring(get_historylength(event.room)); 54 value = get_historylength(event.room);
54 }); 55 });
55 table.insert(event.form, { 56 table.insert(event.form, {
56 name = 'muc#roomconfig_defaulthistorymessages', 57 name = 'muc#roomconfig_defaulthistorymessages',
57 type = 'text-single', 58 type = 'text-single',
59 datatype = "xs:integer";
58 label = 'Default number of history messages returned by room', 60 label = 'Default number of history messages returned by room',
59 desc = "Specify the number of previous messages sent to new users when they join the room"; 61 desc = "Specify the number of previous messages sent to new users when they join the room";
60 value = tostring(get_defaulthistorymessages(event.room)) 62 value = get_defaulthistorymessages(event.room);
61 }); 63 });
62 end, 70-5); 64 end, 70-5);
63 65
64 module:hook("muc-config-submitted/muc#roomconfig_historylength", function(event) 66 module:hook("muc-config-submitted/muc#roomconfig_historylength", function(event)
65 if set_historylength(event.room, event.value) then 67 if set_historylength(event.room, event.value) then