Add logout on shutdown
This commit is contained in:
parent
e2f55d5f26
commit
9b05dd74c0
11
init.lua
11
init.lua
@ -62,7 +62,7 @@ local function msync(s)
|
||||
else -- second time sync -> append since parameter
|
||||
u = u .. "&since="..s
|
||||
end
|
||||
http.fetch({url=u},
|
||||
http.fetch({url=u, method="GET"},
|
||||
function (res)
|
||||
if res == nil then -- received nothing from server
|
||||
minetest.log("error", "matrix_bridge - sync response is nil")
|
||||
@ -70,6 +70,7 @@ local function msync(s)
|
||||
minetest.log("info", "matrix_bridge - not found / timeout")
|
||||
elseif res.code == 404 then
|
||||
minetest.log("error", "matrix_bridge - 404")
|
||||
minetest.log("action", res.data)
|
||||
else
|
||||
local response = minetest.parse_json(res.data)
|
||||
if response ~= nil then
|
||||
@ -145,6 +146,8 @@ minetest.register_chatcommand("msync", {
|
||||
func = function(name, param)
|
||||
if param == "nil" then -- test sync as called from login
|
||||
msync()
|
||||
elseif param == "relogin" then
|
||||
mlogin()
|
||||
elseif #param > 1 then -- test sync with specific 'since' parameter
|
||||
msync(param)
|
||||
else -- test sync with current since parameter
|
||||
@ -153,6 +156,12 @@ minetest.register_chatcommand("msync", {
|
||||
return true, "[matrix_bridge] Fetching from matrix..."
|
||||
end})
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
minetest.log("action", "matrix_bridge - signing out.")
|
||||
local u = MATRIX_SERVER.."/logout/all"
|
||||
http.fetch({url=u, method="POST", function (res) end})
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
if token then
|
||||
|
Loading…
x
Reference in New Issue
Block a user