Mercurial > prosody-modules
diff mod_http_muc_log/mod_http_muc_log.lua @ 3703:7244ff1d62a8
mod_http_muc_log: Expose xml:lang from each message/body #a11y
Individual messages may be in a different language than the main
language of the room.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 09 Oct 2019 21:35:13 +0200 |
parents | caf27826c7b2 |
children | 04ff0de40ba9 |
line wrap: on
line diff
--- a/mod_http_muc_log/mod_http_muc_log.lua Wed Oct 09 21:36:23 2019 +0200 +++ b/mod_http_muc_log/mod_http_muc_log.lua Wed Oct 09 21:35:13 2019 +0200 @@ -294,9 +294,11 @@ local first, last; for key, item, when in iter do - local body = item:get_child_text("body"); + local body_tag = item:get_child("body"); + local body = body_tag and body_tag:get_text(); local subject = item:get_child_text("subject"); local verb = nil; + local lang = body_tag and body_tag.attr["xml:lang"] or item.attr["xml:lang"]; if subject then verb, body = "set the topic to", subject; elseif body and body:sub(1,4) == "/me " then @@ -304,6 +306,7 @@ elseif item.name == "presence" then -- TODO Distinguish between join and presence update verb = item.attr.type == "unavailable" and "has left" or "has joined"; + lang = "en"; end local oob = use_oob and item:get_child("x", "jabber:x:oob"); if body or verb or oob then @@ -313,6 +316,7 @@ time = datetime.time(when); verb = verb; body = body; + lang = lang; nick = select(3, jid_split(item.attr.from)); st_name = item.name; st_type = item.attr.type;