support custom HTML messages in prosody's mod_post_msg plugin.
has been integrated into prosody_modules; see https://code.google.com/p/prosody-modules/source/detail?r=e556219cb43d7af6f2a0564e8abf8a614e661be0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | HG changeset patch # User Christian Weiske <cweiske@cweiske.de> # Date 1392386891 -3600 # Node ID 46f6f3b7c8926da0d79fee2457b25936f33f98d4 # Parent 9700c89f7bf67cc27862743f46f1192e0a1069e9 mod_post_msg: add support for HTML messages diff -r 9700c89f7bf6 -r 46f6f3b7c892 mod_post_msg/mod_post_msg.lua --- a/mod_post_msg/mod_post_msg.lua Thu Jan 23 20:27:14 2014 +0000 +++ 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 |