Mercurial > prosody-modules
comparison mod_storage_muc_log/mod_storage_muc_log.lua @ 2356:49a01b78b45f
mod_storage_muc_log: Address luacheck warnings
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 09 Nov 2016 13:37:58 +0100 |
| parents | e72f9eac51c8 |
| children | 093b70378fa5 |
comparison
equal
deleted
inserted
replaced
| 2355:513332854531 | 2356:49a01b78b45f |
|---|---|
| 1 -- luacheck: ignore 212/self 431/err | |
| 1 | 2 |
| 2 local datamanager = require"core.storagemanager".olddm; | 3 local datamanager = require"core.storagemanager".olddm; |
| 3 local xml_parse = require"util.xml".parse; | 4 local xml_parse = require"util.xml".parse; |
| 4 local data_load, data_store = datamanager.load, datamanager.store; | 5 local data_load, data_store = datamanager.load, datamanager.store; |
| 5 local datastore = "muc_log"; | 6 local datastore = "muc_log"; |
| 46 local function st_with(tag) | 47 local function st_with(tag) |
| 47 local with = tag.attr.type; | 48 local with = tag.attr.type; |
| 48 return with and tag.name .. "<" .. with or tag.name; | 49 return with and tag.name .. "<" .. with or tag.name; |
| 49 end | 50 end |
| 50 | 51 |
| 51 function driver:append(node, key, stanza, when, with) | 52 function driver:append(node, key, stanza, when, with) -- luacheck: ignore 212/key |
| 53 -- luacheck: ignore 311/with | |
| 54 -- 'with' doesn't exist in the original mod_muc_log, so gets derived here | |
| 52 if type(when) ~= "number" then | 55 if type(when) ~= "number" then |
| 53 when, with, stanza = stanza, when, with; | 56 when, with, stanza = stanza, when, with; |
| 54 end | 57 end |
| 55 local today = os_date(datef, when); | 58 local today = os_date(datef, when); |
| 56 local now = os_date(timef, when); | 59 local now = os_date(timef, when); |
| 81 end | 84 end |
| 82 if dates[1] == nil then return noop, 0; end | 85 if dates[1] == nil then return noop, 0; end |
| 83 table.sort(dates); | 86 table.sort(dates); |
| 84 | 87 |
| 85 return coroutine.wrap(function () | 88 return coroutine.wrap(function () |
| 86 local query = query; | |
| 87 local dates = dates; | |
| 88 local start_date = query and query.start and os_date(datef, query.start) or dates[1]; | 89 local start_date = query and query.start and os_date(datef, query.start) or dates[1]; |
| 89 local end_date = query and query["end"] and os_date(datef, query["end"]) or dates[#dates]; | 90 local end_date = query and query["end"] and os_date(datef, query["end"]) or dates[#dates]; |
| 90 local start_time = query and query.start and os_date(timef, query.start) or dates[1]; | 91 local start_time = query and query.start and os_date(timef, query.start) or dates[1]; |
| 91 local end_time = query and query["end"] and os_date(timef, query["end"]) or dates[#dates]; | 92 local end_time = query and query["end"] and os_date(timef, query["end"]) or dates[#dates]; |
| 92 local query_with = query and query.with; | 93 local query_with = query and query.with; |
| 118 if seek_once then | 119 if seek_once then |
| 119 inner_start = tonumber(seek_once:match("_(%d+)$")); | 120 inner_start = tonumber(seek_once:match("_(%d+)$")); |
| 120 inner_start = inner_start + (query and query.reverse and -1 or 1); | 121 inner_start = inner_start + (query and query.reverse and -1 or 1); |
| 121 seek_once = nil; | 122 seek_once = nil; |
| 122 end | 123 end |
| 123 for i = inner_start, inner_stop, inner_step do | 124 for i = inner_start, inner_stop, inner_step do -- luacheck: ignore 423/i |
| 124 item, err = data[i]; | 125 item, err = data[i], nil; |
| 125 if item then | 126 if item then |
| 126 item, err = xml_parse(item); | 127 item, err = xml_parse(item); |
| 127 end | 128 end |
| 128 if item then | 129 if item then |
| 129 time = item.attr.time; | 130 time = item.attr.time; |
