From 04cf7b139e38aabc0bdf75428484bdba72968100 Mon Sep 17 00:00:00 2001 From: - <-> Date: Fri, 28 Jan 2022 19:07:30 -0800 Subject: [PATCH] cleaned up MatrixChat:get_sync_table() --- init.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 578dfb1..c729021 100644 --- a/init.lua +++ b/init.lua @@ -66,16 +66,14 @@ end -- GET /sync function MatrixChat:get_sync_table(timeout) local params = {} - -- no filter param if self.since ~= nil then - params[1] = "since=" .. self.since + table.insert(params, "since=" .. self.since) end if timeout ~= nil then - -- if timeout is defined and since took the starting '?' - params[2] = "timeout=" .. timeout + table.insert(params, "timeout=" .. timeout) end local u = self.server .."/_matrix/client/r0/sync" - if params[1] ~= nil then + if #params > 0 then u = u .. "?" .. table.concat(params, "&") end local h = {"Authorization: Bearer " .. self.token}