Mercurial > prosody-modules
diff mod_nodeinfo2/mod_nodeinfo2.lua @ 3710:7f5ce667d93e
mod_nodeinfo2: Store and restore the total message count.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 10 Oct 2019 21:07:45 +0200 |
parents | 0a800463bc08 |
children | 263f5f1ee71f |
line wrap: on
line diff
--- a/mod_nodeinfo2/mod_nodeinfo2.lua Thu Oct 10 20:43:49 2019 +0200 +++ b/mod_nodeinfo2/mod_nodeinfo2.lua Thu Oct 10 21:07:45 2019 +0200 @@ -37,15 +37,21 @@ week_users = nil; end +local message_count_store = module:open_store("message_count"); +local message_count = message_count_store:get("message_count"); + module:provides("http", { default_path = "/.well-known/x-nodeinfo2"; route = { GET = function (event) local stats, changed_only, extras = get_stats(); - local message_count = nil; for stat, _ in pairs(stats) do if stat == "/*/mod_measure_message_e2ee/message:rate" then - message_count = extras[stat].total; + local new_message_count = extras[stat].total; + if new_message_count ~= message_count then + message_count = new_message_count; + message_count_store:set("message_count", message_count); + end end end