Fix identation.

This commit is contained in:
John Livingston 2021-07-19 16:19:06 +02:00
parent 8674ee3f99
commit b65d6ddde7
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC

View File

@ -8,7 +8,7 @@ local all_rooms = rawget(mod_muc, "all_rooms")
module:depends"http"; module:depends"http";
function check_auth(routes) function check_auth(routes)
local function check_request_auth(event) local function check_request_auth(event)
local apikey = module:get_option_string("peertubelivechat_list_rooms_apikey", "") local apikey = module:get_option_string("peertubelivechat_list_rooms_apikey", "")
if apikey == "" then if apikey == "" then
return false, 500; return false, 500;
@ -16,25 +16,25 @@ function check_auth(routes)
if event.request.headers.authorization ~= "Bearer " .. apikey then if event.request.headers.authorization ~= "Bearer " .. apikey then
return false, 401; return false, 401;
end end
return true; return true;
end end
for route, handler in pairs(routes) do for route, handler in pairs(routes) do
routes[route] = function (event, ...) routes[route] = function (event, ...)
local permit, code = check_request_auth(event); local permit, code = check_request_auth(event);
if not permit then if not permit then
return code; return code;
end end
return handler(event, ...); return handler(event, ...);
end; end;
end end
return routes; return routes;
end end
local function list_rooms(event) local function list_rooms(event)
local request, response = event.request, event.response; local request, response = event.request, event.response;
local rooms_json = array(); local rooms_json = array();
for room in all_rooms() do for room in all_rooms() do
local localpart = jid_split(room.jid); local localpart = jid_split(room.jid);
rooms_json:push({ rooms_json:push({
jid = room.jid; jid = room.jid;
@ -43,14 +43,14 @@ local function list_rooms(event)
lang = room.get_language and room:get_language(); lang = room.get_language and room:get_language();
description = room:get_description(); description = room:get_description();
}) })
end end
event.response.headers["Content-Type"] = "application/json"; event.response.headers["Content-Type"] = "application/json";
return json.encode_array(rooms_json); return json.encode_array(rooms_json);
end end
module:provides("http", { module:provides("http", {
route = check_auth { route = check_auth {
["GET /list-rooms"] = list_rooms; ["GET /list-rooms"] = list_rooms;
}; };
}); });