Software /
code /
prosody-modules
Comparison
mod_push2/mod_push2.lua @ 5683:bebb10fa5787
mod_push2: Add back body truncation logic
author | Stephen Paul Weber <singpolyma@singpolyma.net> |
---|---|
date | Tue, 19 Sep 2023 21:33:40 -0500 |
parent | 5682:4d1a3de56c3d |
child | 5686:a1d22d6efb3d |
comparison
equal
deleted
inserted
replaced
5682:4d1a3de56c3d | 5683:bebb10fa5787 |
---|---|
197 else | 197 else |
198 return nil | 198 return nil |
199 end | 199 end |
200 end) | 200 end) |
201 envelope_bytes = tostring(envelope) | 201 envelope_bytes = tostring(envelope) |
202 end | |
203 if string.len(envelope_bytes) > max_data_size then | |
204 local body = stanza:get_child_text("body") | |
205 if string.len(body) > 50 then | |
206 stanza_clone:maptags(function(el) | |
207 if el.name == "body" then | |
208 return nil | |
209 else | |
210 return el | |
211 end | |
212 end) | |
213 | |
214 body = string.gsub(string.gsub("\n" .. body, "\n>[^\n]*", ""), "^%s", "") | |
215 stanza_clone:body(body:sub(1, utf8.offset(body, 50)) .. "…") | |
216 envelope_bytes = tostring(envelope) | |
217 end | |
202 end | 218 end |
203 if string.len(envelope_bytes) > max_data_size then | 219 if string.len(envelope_bytes) > max_data_size then |
204 -- If still too big, get aggressive | 220 -- If still too big, get aggressive |
205 stanza_clone:maptags(function(el) | 221 stanza_clone:maptags(function(el) |
206 if el.name == "body" or | 222 if el.name == "body" or |