Mercurial > prosody-modules
changeset 1302:e556219cb43d
mod_post_msg: add support for HTML messages
author | Christian Weiske <cweiske@cweiske.de> |
---|---|
date | Fri, 14 Feb 2014 15:08:11 +0100 |
parents | 6e4ebdc9b46b |
children | 8a3f3f485675 |
files | mod_post_msg/mod_post_msg.lua |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_post_msg/mod_post_msg.lua Sat Feb 08 16:59:10 2014 +0100 +++ b/mod_post_msg/mod_post_msg.lua Fri Feb 14 15:08:11 2014 +0100 @@ -6,6 +6,7 @@ local test_password = require "core.usermanager".test_password; local b64_decode = require "util.encodings".base64.decode; local formdecode = require "net.http".formdecode; +local xml = require"util.xml"; local function require_valid_user(f) return function(event, path) @@ -46,8 +47,16 @@ end elseif body_type == "application/x-www-form-urlencoded" then local post_body = formdecode(request.body); - message = msg({ to = post_body.to or to, from = authed_user, + message = msg({ to = post_body.to or to, from = authed_user, type = post_body.type or "chat"}, post_body.body); + if post_body.html then + local html, err = xml.parse(post_body.html); + if not html then + module:log("warn", "mod_post_msg: invalid XML: %s", err); + return 400; + end + message:tag("html", {xmlns="http://jabber.org/protocol/xhtml-im"}):add_child(html):up(); + end else return 415; end