Mercurial > prosody-modules
comparison mod_rest/mod_rest.lua @ 3798:9b4fd2553365
mod_rest: Handle receipt requests on message stanzas
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 30 Dec 2019 05:18:52 +0100 |
| parents | ed5d7586a61e |
| children | a1f1f703d604 |
comparison
equal
deleted
inserted
replaced
| 3797:ed5d7586a61e | 3798:9b4fd2553365 |
|---|---|
| 118 }; | 118 }; |
| 119 | 119 |
| 120 local function handle_stanza(event) | 120 local function handle_stanza(event) |
| 121 local stanza, origin = event.stanza, event.origin; | 121 local stanza, origin = event.stanza, event.origin; |
| 122 local reply_needed = stanza.name == "iq"; | 122 local reply_needed = stanza.name == "iq"; |
| 123 local receipt; | |
| 124 | |
| 125 if stanza.name == "message" and stanza.attr.id and stanza:get_child("urn:xmpp:receipts", "request") then | |
| 126 reply_needed = true; | |
| 127 receipt = st.stanza("received", { xmlns = "urn:xmpp:receipts", id = stanza.id }); | |
| 128 end | |
| 123 | 129 |
| 124 http.request(rest_url, { | 130 http.request(rest_url, { |
| 125 body = tostring(stanza), | 131 body = tostring(stanza), |
| 126 headers = { | 132 headers = { |
| 127 ["Content-Type"] = "application/xmpp+xml", | 133 ["Content-Type"] = "application/xmpp+xml", |
| 177 else | 183 else |
| 178 reply = st.error_reply(stanza, "cancel", "undefined-condition", reply_text); | 184 reply = st.error_reply(stanza, "cancel", "undefined-condition", reply_text); |
| 179 end | 185 end |
| 180 end | 186 end |
| 181 | 187 |
| 188 if receipt then | |
| 189 reply:add_direct_child(receipt); | |
| 190 end | |
| 191 | |
| 182 origin.send(reply); | 192 origin.send(reply); |
| 183 end); | 193 end); |
| 184 | 194 |
| 185 return true; | 195 return true; |
| 186 end | 196 end |
