Software /
code /
prosody-modules
Comparison
mod_muc_log/mod_muc_log.lua @ 81:9ceeab822e40
mod_muc_log: revert changes of last commit (bed9a6b40f)
author | Thilo Cestonaro <thilo@cestona.ro> |
---|---|
date | Sun, 01 Nov 2009 17:22:21 +0100 |
parent | 80:bed9a6b40fae |
child | 85:83494de806a4 |
comparison
equal
deleted
inserted
replaced
80:bed9a6b40fae | 81:9ceeab822e40 |
---|---|
11 local serialize = require "util.serialization".serialize; | 11 local serialize = require "util.serialization".serialize; |
12 local datamanager = require "util.datamanager"; | 12 local datamanager = require "util.datamanager"; |
13 local data_load, data_store, data_getpath = datamanager.load, datamanager.store, datamanager.getpath; | 13 local data_load, data_store, data_getpath = datamanager.load, datamanager.store, datamanager.getpath; |
14 local datastore = "muc_log"; | 14 local datastore = "muc_log"; |
15 local config = {}; | 15 local config = {}; |
16 local verifyAuthRequest = module:require "verifyhttpauth".verifyHttpAuthRequest; | |
17 | |
18 | 16 |
19 | 17 |
20 --[[ LuaFileSystem | 18 --[[ LuaFileSystem |
21 * URL: http://www.keplerproject.org/luafilesystem/index.html | 19 * URL: http://www.keplerproject.org/luafilesystem/index.html |
22 * Install: luarocks install luafilesystem | 20 * Install: luarocks install luafilesystem |
421 return tmp; | 419 return tmp; |
422 else | 420 else |
423 return generateDayListSiteContentByRoom(bareRoomJid); -- fallback | 421 return generateDayListSiteContentByRoom(bareRoomJid); -- fallback |
424 end | 422 end |
425 end | 423 end |
426 local requests = {}; | 424 |
427 function handle_request(method, body, request) | 425 function handle_request(method, body, request) |
428 local query = splitQuery(request.url.query); | 426 local query = splitQuery(request.url.query); |
429 local node, host = grepRoomJid(request.url.path); | 427 local node, host = grepRoomJid(request.url.path); |
430 | 428 |
431 if node ~= nil and host ~= nil then | 429 if node ~= nil and host ~= nil then |
437 else | 435 else |
438 local subject = "" | 436 local subject = "" |
439 if room._data ~= nil and room._data.subject ~= nil then | 437 if room._data ~= nil and room._data.subject ~= nil then |
440 subject = room._data.subject; | 438 subject = room._data.subject; |
441 end | 439 end |
442 local doc = createDoc(parseDay(bare, subject, query)); | 440 return createDoc(parseDay(bare, subject, query)); |
443 local id = "thisIsTheId"; | |
444 requests[id] = request; | |
445 requests[id].doc = doc; | |
446 | |
447 verifyAuthRequest(request.url.path .. "?" .. request.url.query, "thilo@cestona.ro", id, function (id, confirmed) | |
448 if confirmed and requests[id] then | |
449 requests[id].send(requests[id].doc); | |
450 end | |
451 end) | |
452 return true; | |
453 end | 441 end |
454 else | 442 else |
455 return createDoc(generateRoomListSiteContent()); | 443 return createDoc(generateRoomListSiteContent()); |
456 end | 444 end |
457 else | 445 else |
458 return createDoc(generateRoomListSiteContent()); | 446 return createDoc(generateRoomListSiteContent()); |
459 end | 447 end |
460 return; | 448 return; |
461 end | 449 end |
462 | 450 |
463 config = config_get(module:get_host(), "core", "muc_log") or {}; | 451 config = config_get(module:get_host(), "core", "muc_log"); |
464 | 452 |
465 httpserver.new_from_config({ config.http_port or true }, handle_request, { base = "muc_log" }); | 453 httpserver.new_from_config({ config.http_port or true }, handle_request, { base = "muc_log" }); |
466 | 454 |
467 module:hook("message/bare", logIfNeeded, 500); | 455 module:hook("message/bare", logIfNeeded, 500); |
468 module:hook("pre-message/bare", logIfNeeded, 500); | 456 module:hook("pre-message/bare", logIfNeeded, 500); |