diff options
author | Kim Alvefur <zash@zash.se> | 2021-10-26 13:31:40 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-10-26 13:31:40 +0200 |
commit | 6b5ab097ae0d9f673c0c68ba8f228949ad13b6f2 (patch) | |
tree | d60a99036380ce17a1d273c18b2fd2e8bee74f3f /plugins/mod_mam/mod_mam.lua | |
parent | 851127ecd70c9c7e5e5c13565d26b908a020b69e (diff) | |
download | prosody-6b5ab097ae0d9f673c0c68ba8f228949ad13b6f2.tar.gz prosody-6b5ab097ae0d9f673c0c68ba8f228949ad13b6f2.zip |
mod_mam: Use util.dataforms timestamp validation
Diffstat (limited to 'plugins/mod_mam/mod_mam.lua')
-rw-r--r-- | plugins/mod_mam/mod_mam.lua | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index afeef82b..facf5bc0 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -35,7 +35,7 @@ local is_stanza = st.is_stanza; local tostring = tostring; local time_now = os.time; local m_min = math.min; -local timestamp, timestamp_parse, datestamp = import( "util.datetime", "datetime", "parse", "date"); +local timestamp, datestamp = import( "util.datetime", "datetime", "date"); local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50); local strip_tags = module:get_option_set("dont_archive_namespaces", { "http://jabber.org/protocol/chatstates" }); @@ -77,10 +77,10 @@ module:hook("iq/self/"..xmlns_mam..":prefs", function(event) end); local query_form = dataform { - { name = "FORM_TYPE"; type = "hidden"; value = xmlns_mam; }; - { name = "with"; type = "jid-single"; }; - { name = "start"; type = "text-single" }; - { name = "end"; type = "text-single"; }; + { name = "FORM_TYPE"; type = "hidden"; value = xmlns_mam }; + { name = "with"; type = "jid-single" }; + { name = "start"; type = "text-single"; datatype = "xs:dateTime" }; + { name = "end"; type = "text-single"; datatype = "xs:dateTime" }; }; if archive.caps and archive.caps.full_id_range then @@ -134,15 +134,6 @@ module:hook("iq-set/self/"..xmlns_mam..":query", function(event) qwith = qwith and jid_bare(qwith); -- dataforms does jidprep end - if qstart or qend then -- Validate timestamps - local vstart, vend = (qstart and timestamp_parse(qstart)), (qend and timestamp_parse(qend)); - if (qstart and not vstart) or (qend and not vend) then - origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid timestamp")) - return true; - end - qstart, qend = vstart, vend; - end - -- RSM stuff local qset = rsm.get(query); local qmax = m_min(qset and qset.max or default_max_items, max_max_items); |