# HG changeset patch # User Kim Alvefur # Date 1577679289 -3600 # Node ID d1ad10b76b00ebd51a67ce2ca72b0aa7a439b209 # Parent f51308fcba83d3d4a4c9778dc1b6ed3f457ac8e7 mod_rest: Catch one (1) reply to a POST-ed stanza from an internal source This will primarily cover error replies, and only those generated by the same Prosody instance using the `origin.reply()` method. diff -r f51308fcba83 -r d1ad10b76b00 mod_rest/README.markdown --- a/mod_rest/README.markdown Mon Dec 30 04:07:25 2019 +0100 +++ b/mod_rest/README.markdown Mon Dec 30 05:14:49 2019 +0100 @@ -51,6 +51,11 @@ ' ``` +Replies to other kinds of stanzas that are generated by the same Prosody +instance *MAY* be returned in the HTTP response. Replies from other +entities (connected clients or remote servers) will not be returned, but +can be forwarded via the callback API described in the next section. + ## Receiving stanzas TL;DR: Set this webhook callback URL, get XML `POST`-ed there. diff -r f51308fcba83 -r d1ad10b76b00 mod_rest/mod_rest.lua --- a/mod_rest/mod_rest.lua Mon Dec 30 04:07:25 2019 +0100 +++ b/mod_rest/mod_rest.lua Mon Dec 30 05:14:49 2019 +0100 @@ -63,7 +63,13 @@ end end); elseif payload.name == "message" or payload.name == "presence" then - if module:send(payload) then + local origin = {}; + function origin.send(stanza) + response:send(tostring(stanza)); + return true; + end + response.headers.content_type = "application/xmpp+xml"; + if module:send(payload, origin) then return 202; else return 500;