Mercurial > prosody-modules
comparison 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 |
comparison
equal
deleted
inserted
replaced
3702:caf27826c7b2 | 3703:7244ff1d62a8 |
---|---|
292 return 500; | 292 return 500; |
293 end | 293 end |
294 | 294 |
295 local first, last; | 295 local first, last; |
296 for key, item, when in iter do | 296 for key, item, when in iter do |
297 local body = item:get_child_text("body"); | 297 local body_tag = item:get_child("body"); |
298 local body = body_tag and body_tag:get_text(); | |
298 local subject = item:get_child_text("subject"); | 299 local subject = item:get_child_text("subject"); |
299 local verb = nil; | 300 local verb = nil; |
301 local lang = body_tag and body_tag.attr["xml:lang"] or item.attr["xml:lang"]; | |
300 if subject then | 302 if subject then |
301 verb, body = "set the topic to", subject; | 303 verb, body = "set the topic to", subject; |
302 elseif body and body:sub(1,4) == "/me " then | 304 elseif body and body:sub(1,4) == "/me " then |
303 verb, body = body:sub(5), nil; | 305 verb, body = body:sub(5), nil; |
304 elseif item.name == "presence" then | 306 elseif item.name == "presence" then |
305 -- TODO Distinguish between join and presence update | 307 -- TODO Distinguish between join and presence update |
306 verb = item.attr.type == "unavailable" and "has left" or "has joined"; | 308 verb = item.attr.type == "unavailable" and "has left" or "has joined"; |
309 lang = "en"; | |
307 end | 310 end |
308 local oob = use_oob and item:get_child("x", "jabber:x:oob"); | 311 local oob = use_oob and item:get_child("x", "jabber:x:oob"); |
309 if body or verb or oob then | 312 if body or verb or oob then |
310 local line = { | 313 local line = { |
311 key = key; | 314 key = key; |
312 datetime = datetime.datetime(when); | 315 datetime = datetime.datetime(when); |
313 time = datetime.time(when); | 316 time = datetime.time(when); |
314 verb = verb; | 317 verb = verb; |
315 body = body; | 318 body = body; |
319 lang = lang; | |
316 nick = select(3, jid_split(item.attr.from)); | 320 nick = select(3, jid_split(item.attr.from)); |
317 st_name = item.name; | 321 st_name = item.name; |
318 st_type = item.attr.type; | 322 st_type = item.attr.type; |
319 }; | 323 }; |
320 if oob then | 324 if oob then |