Check token before sync
This commit is contained in:
parent
4bd0e718a2
commit
5dfcf905f4
5
init.lua
5
init.lua
@ -78,6 +78,9 @@ function MatrixChat:get_sync_table(timeout)
|
||||
end
|
||||
|
||||
function MatrixChat:sync(timeout)
|
||||
if self.token == nil then
|
||||
return
|
||||
end
|
||||
http.fetch(MatrixChat:get_sync_table(timeout),
|
||||
function(res)
|
||||
if res == nil then -- received nothing from server
|
||||
@ -102,7 +105,7 @@ function MatrixChat:login()
|
||||
local u = self.server .."/_matrix/client/r0/login"
|
||||
local d = '{"type":"m.login.password","password":"'.. self.password ..'","identifier":{"type":"m.id.user","user":"'.. self.username ..'"}}'
|
||||
local h = {"Content-Type: application/json"}
|
||||
http.fetch({url=u, method="POST", extra_headers=h, data=d},
|
||||
http.fetch({url=u, method="POST", extra_headers=h, post_data=d},
|
||||
function(res)
|
||||
if res.code == 200 then
|
||||
minetest.log("action", res.data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user