From 5a23cb5b85d5e1e4511d4a973ba7d09f0e310991 Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Thu, 30 Jun 2016 00:12:55 +0300 Subject: [PATCH] Use the /sync endpoing instead /initialSync The /initialSync endpoint is deprecated. This renames the api:initial_sync() method to api:sync(), and uses the new endpoint. --- matrix/api.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/matrix/api.lua b/matrix/api.lua index 268348d..e13a3fe 100644 --- a/matrix/api.lua +++ b/matrix/api.lua @@ -72,9 +72,27 @@ function API:__tostring() return self.__name .. "{" .. self.base_url .. "}" end - -function API:initial_sync(limit) - return self:_send("GET", "/initialSync", { limit = limit or 1 }) +---- +-- | Option | Type | Default Value | +-- |:=========|:========|===============| +-- | filter | string | nil | +-- | since | string | nil | +-- | full | boolean | false | +-- | online | boolean | true | +-- | timeout | number | nil | +---- +function API:sync(options) + local params + if options then + params = { + filter = options.filter, + ince = options.since, + full_state = options.full or false, + set_presence = online and nil or "offline", + timeout = options.timeout, + } + end + return self:_send("GET", "/sync", params) end function API:register(login_type, params)