Check token before sync

This commit is contained in:
Pascal Engélibert 2022-01-31 14:29:19 +01:00
parent 4bd0e718a2
commit 5dfcf905f4
Signed by: tuxmain
GPG Key ID: 3504BC6D362F7DCA
1 changed files with 9 additions and 6 deletions

View File

@ -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)