Software /
code /
prosody-modules
Changeset
3059:14d8f2a9d5f4
mod_http_muc_log: Base read-access on whether anyone would be able to join (like MUC)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 28 May 2018 20:11:37 +0200 |
parents | 3058:4d46658b6998 |
children | 3060:982668000163 |
files | mod_http_muc_log/mod_http_muc_log.lua |
diffstat | 1 files changed, 17 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_http_muc_log/mod_http_muc_log.lua Mon May 28 20:04:46 2018 +0200 +++ b/mod_http_muc_log/mod_http_muc_log.lua Mon May 28 20:11:37 2018 +0200 @@ -48,7 +48,8 @@ end end -local function public_room(room) -- : boolean +-- Whether room can be joined by anyone +local function open_room(room) -- : boolean if type(room) == "string" then room = get_room(room); end @@ -56,11 +57,11 @@ return nil; end - if (room.get_hidden or room.is_hidden)(room) then - return nil; + if (room.get_members_only or room.is_members_only)(room) then + return false; end - if (room.get_members_only or room.is_members_only)(room) then + if room:get_password() then return false; end @@ -97,7 +98,12 @@ local response = event.response; local room = nodeprep(path:match("^(.*)/$")); - if not room or not public_room(room) then return end + local is_open = open_room(room); + if is_open == nil then + return -- implicit 404 + elseif is_open == false then + return 403; + end -- Collect each date that has messages -- convert it to a year / month / day tree @@ -200,7 +206,12 @@ if not room then return years_page(event, path); end - if not public_room(room) then return end + local is_open = open_room(room); + if is_open == nil then + return -- implicit 404 + elseif is_open == false then + return 403; + end local day_start = datetime.parse(date.."T00:00:00Z"); local logs, i = {}, 1;