Software /
code /
prosody-modules
Comparison
mod_rest/jsonmap.lib.lua @ 4035:270cd50852be
mod_rest: Map xml:lang to/from JSON
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 29 May 2020 12:04:04 +0200 |
parent | 4021:1925d63eec6b |
child | 4251:d33b480befcb |
comparison
equal
deleted
inserted
replaced
4034:a359972d246e | 4035:270cd50852be |
---|---|
11 kind = "attr", | 11 kind = "attr", |
12 type = "attr", | 12 type = "attr", |
13 to = "attr", | 13 to = "attr", |
14 from = "attr", | 14 from = "attr", |
15 id = "attr", | 15 id = "attr", |
16 lang = "attr", | |
16 | 17 |
17 -- basic message | 18 -- basic message |
18 body = "text_tag", | 19 body = "text_tag", |
19 subject = "text_tag", | 20 subject = "text_tag", |
20 thread = "text_tag", | 21 thread = "text_tag", |
442 kind = s.name, | 443 kind = s.name, |
443 type = s.attr.type, | 444 type = s.attr.type, |
444 to = s.attr.to, | 445 to = s.attr.to, |
445 from = s.attr.from, | 446 from = s.attr.from, |
446 id = s.attr.id, | 447 id = s.attr.id, |
448 lang = s.attr["xml:lang"], | |
447 }; | 449 }; |
448 if s.name == "presence" and not s.attr.type then | 450 if s.name == "presence" and not s.attr.type then |
449 t.type = "available"; | 451 t.type = "available"; |
450 end | 452 end |
451 | 453 |
536 local s = st.stanza(kind or "message", { | 538 local s = st.stanza(kind or "message", { |
537 type = t_type; | 539 type = t_type; |
538 to = str(t.to) and jid.prep(t.to); | 540 to = str(t.to) and jid.prep(t.to); |
539 from = str(t.to) and jid.prep(t.from); | 541 from = str(t.to) and jid.prep(t.from); |
540 id = str(t.id), | 542 id = str(t.id), |
543 ["xml:lang"] = str(t.lang), | |
541 }); | 544 }); |
542 | 545 |
543 if t.to and not s.attr.to then | 546 if t.to and not s.attr.to then |
544 return nil, "invalid-jid-to"; | 547 return nil, "invalid-jid-to"; |
545 end | 548 end |