Compare commits

...
9 Commits
Author SHA1 Message Date
eric 5062c9dd15 Trying again 2026-04-20 12:20:25 -04:00
eric f844be04b0 make_unimplemented_handler 2026-04-20 12:13:51 -04:00
eric eb8fff42bf One more 2026-04-20 12:08:30 -04:00
eric d94c1342b0 Additional bug fixes 2026-04-20 12:02:12 -04:00
eric cb4945d469 Extra checks 2026-04-20 11:50:11 -04:00
eric 5bbb2e6afa syntax 2026-04-20 11:11:30 -04:00
eric 5756d8ba39 Close parenthases 2026-04-20 10:44:01 -04:00
eric 9e95b1fd78 Handle nil value in client _sync 2026-04-20 10:35:36 -04:00
joenas 151355a790 Trying to get things to work with minetest mod security:
Require is only allowed at init, with request_insecure_environment()
2017-08-07 11:46:06 +02:00
3 changed files with 26 additions and 19 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ function API:sync(options)
filter = options.filter,
since = options.since,
full_state = options.full or false,
set_presence = online and nil or "offline",
set_presence = options.online and nil or "offline",
timeout = options.timeout,
}
end
+15 -10
View File
@@ -228,6 +228,7 @@ function Room:get_alias_or_id()
end
end
local make_unimplemented_handler
local make_unimplemented_handler = function (self, event)
local env_value = os.getenv("MATRIX_CLIENT_LOG_UNHANDLED_EVENTS")
if env_value and #env_value > 0 and env_value ~= "0" then
@@ -445,16 +446,20 @@ function Client:_sync(options)
for _, kind in ipairs { "join", "invite", "leave" } do
local handle = self["_sync_handle_room__" .. kind]
for room_id, room_data in pairs(response.rooms[kind]) do
self._log("sync: %s %s", kind, room_id)
-- XXX: Maybe this is abusing pcall() too much to allow handler
-- code to bail and continue with the next room instead of
-- completely failing to sync. Dunno.
local ok, err = xpcall(handle, xpcall_add_traceback, self, room_id, room_data)
if not ok then
self._log("sync: Error handling '%s' event for room %s:\n%s", kind, room_id, err)
self._log("sync: Event payload: %s", json.encode(room_data))
end
if response.rooms == nil or response.rooms[kind] == nil then
self._log("sync: Error syncing rooms (nil value)")
else
for room_id, room_data in pairs(response.rooms[kind]) do
self._log("sync: %s %s", kind, room_id)
-- XXX: Maybe this is abusing pcall() too much to allow handler
-- code to bail and continue with the next room instead of
-- completely failing to sync. Dunno.
local ok, err = xpcall(handle, xpcall_add_traceback, self, room_id, room_data)
if not ok then
self._log("sync: Error handling '%s' event for room %s:\n%s", kind, room_id, err)
self._log("sync: Event payload: %s", json.encode(room_data))
end
end
end
end
end
+10 -8
View File
@@ -9,16 +9,18 @@
local urlescape = require "socket.url" .escape
local stringsource = require "ltn12" .source.string
local tablesink = require "ltn12" .sink.table
local request_https = require "ssl.https" .request
local request_http = require "socket.http" .request
local request_https = function (...)
request_https = require "ssl.https" .request
return request_https(...)
end
-- local request_https = function (...)
-- request_https = require "ssl.https" .request
-- return request_https(...)
-- end
local request_http = function (...)
request_http = require "socket.http" .request
return request_http(...)
end
-- local request_http = function (...)
-- request_http = require "socket.http" .request
-- return request_http(...)
-- end
local function make_request(t)
if t.url:sub(1, #"https://") == "https://" then