From 9b05dd74c0ab1f2aed3059ebcc5da020dd07c8cb Mon Sep 17 00:00:00 2001 From: - <-> Date: Sun, 23 Jan 2022 13:36:05 -0800 Subject: [PATCH] Add logout on shutdown --- init.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index fad87c4..1a06f91 100644 --- a/init.lua +++ b/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