Mercurial > prosody-modules
comparison mod_pubsub_eventsource/mod_pubsub_eventsource.lua @ 4508:0329cf8cdecb
mod_pubsub_eventsource: Fix processing of newlines
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 12 Mar 2021 21:32:03 +0100 |
| parents | 7dbde05b48a9 |
| children |
comparison
equal
deleted
inserted
replaced
| 4507:86a97e7572b2 | 4508:0329cf8cdecb |
|---|---|
| 47 local clientlist = streams[node]; | 47 local clientlist = streams[node]; |
| 48 local item = event.item; | 48 local item = event.item; |
| 49 if (item.name == "json" and item.attr.xmlns == "urn:xmpp:json:0") or (item.name == "data" and item.attr.xmlns == "https://prosody.im/protocol/data") then | 49 if (item.name == "json" and item.attr.xmlns == "urn:xmpp:json:0") or (item.name == "data" and item.attr.xmlns == "https://prosody.im/protocol/data") then |
| 50 item = item[1]; | 50 item = item[1]; |
| 51 end | 51 end |
| 52 local data = "data: "..tostring(item):gsub("\n", "\ndata: \n").."\n\n"; | 52 local data = "data: "..tostring(item):gsub("\n", "\ndata: ").."\n\n"; |
| 53 if not clientlist then module:log("debug", "No clients for %q", node); return; end | 53 if not clientlist then module:log("debug", "No clients for %q", node); return; end |
| 54 for response, conn in pairs(clientlist) do | 54 for response, conn in pairs(clientlist) do |
| 55 conn:write(data); | 55 conn:write(data); |
| 56 end | 56 end |
| 57 end | 57 end |
