# HG changeset patch # User Kim Alvefur # Date 1660490911 -7200 # Node ID 781772c8b6d99da9213bf83c20ef9517d01afefd # Parent 4c1d3f8170638bbf9cab861a36ebbc2c0332d452 mod_mam: Store archives with sub-second precision timestamps Changes sub-second part of example timestamp to .5 in order to avoid floating point issues. Some clients use timestamps when ordering messages which can lead to messages having the same timestamp ending up in the wrong order. It would be better to preserve the order messages are sent in, which is the order they were stored in. diff -r 4c1d3f817063 -r 781772c8b6d9 plugins/mod_mam/mod_mam.lua --- a/plugins/mod_mam/mod_mam.lua Sun Aug 14 16:57:31 2022 +0200 +++ b/plugins/mod_mam/mod_mam.lua Sun Aug 14 17:28:31 2022 +0200 @@ -34,9 +34,9 @@ local is_stanza = st.is_stanza; local tostring = tostring; -local time_now = os.time; +local time_now = require "util.time".now; local m_min = math.min; -local timestamp, datestamp = import( "util.datetime", "datetime", "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" }); diff -r 4c1d3f817063 -r 781772c8b6d9 spec/scansion/mam_extended.scs --- a/spec/scansion/mam_extended.scs Sun Aug 14 16:57:31 2022 +0200 +++ b/spec/scansion/mam_extended.scs Sun Aug 14 17:28:31 2022 +0200 @@ -45,8 +45,8 @@ Romeo receives: - - + + @@ -59,7 +59,7 @@ - + Hello @@ -71,7 +71,7 @@ - + U there? @@ -98,7 +98,7 @@ - + U there? @@ -110,7 +110,7 @@ - + Hello diff -r 4c1d3f817063 -r 781772c8b6d9 spec/scansion/prosody.cfg.lua --- a/spec/scansion/prosody.cfg.lua Sun Aug 14 16:57:31 2022 +0200 +++ b/spec/scansion/prosody.cfg.lua Sun Aug 14 17:28:31 2022 +0200 @@ -6,8 +6,8 @@ end package.preload["util.time"] = function () return { - now = function () return 1219439344.1; end; - monotonic = function () return 0.1; end; + now = function () return 1219439344.5; end; + monotonic = function () return 0.5; end; } end