Mercurial > prosody-modules
comparison mod_csi_battery_saver/mod_csi_battery_saver.lua @ 2737:f43c77c69a8a
mod_csi_battery_saver: Clone stanza pushed to queue
author | Michel Le Bihan <michel@lebihan.pl> |
---|---|
date | Tue, 15 Aug 2017 21:14:55 +0200 |
parents | b5fae17e4403 |
children | 69248dcd7cff |
comparison
equal
deleted
inserted
replaced
2736:fff185e7ab73 | 2737:f43c77c69a8a |
---|---|
7 local s_match = string.match; | 7 local s_match = string.match; |
8 local s_sub = string.sub; | 8 local s_sub = string.sub; |
9 local jid = require "util.jid"; | 9 local jid = require "util.jid"; |
10 local new_queue = require "util.queue".new; | 10 local new_queue = require "util.queue".new; |
11 local datetime = require "util.datetime"; | 11 local datetime = require "util.datetime"; |
12 local clone = require "util.stanza".clone; | |
12 | 13 |
13 local xmlns_delay = "urn:xmpp:delay"; | 14 local xmlns_delay = "urn:xmpp:delay"; |
14 | 15 |
15 -- a log id for this module instance | 16 -- a log id for this module instance |
16 local id = s_sub(require "util.hashes".sha256(datetime.datetime(), true), 1, 4); | 17 local id = s_sub(require "util.hashes".sha256(datetime.datetime(), true), 1, 4); |
54 flush = true; | 55 flush = true; |
55 return q:flush(); | 56 return q:flush(); |
56 end | 57 end |
57 local push = q.push; | 58 local push = q.push; |
58 function q:push(item) | 59 function q:push(item) |
59 local ok = push(self, item); | 60 local ok = push(self, clone(item)); |
60 if not ok then | 61 if not ok then |
61 q:flush(); | 62 q:flush(); |
62 output(item, self); | 63 output(item, self); |
63 elseif flush then | 64 elseif flush then |
64 return q:flush(); | 65 return q:flush(); |