# HG changeset patch # User Stephen Paul Weber # Date 1695177220 18000 # Node ID bebb10fa578724680fa49c2c668d60538b723f75 # Parent 4d1a3de56c3de20d511fd603bcacfe08995c135d mod_push2: Add back body truncation logic diff -r 4d1a3de56c3d -r bebb10fa5787 mod_push2/mod_push2.lua --- a/mod_push2/mod_push2.lua Tue Sep 19 21:21:17 2023 -0500 +++ b/mod_push2/mod_push2.lua Tue Sep 19 21:33:40 2023 -0500 @@ -201,6 +201,22 @@ envelope_bytes = tostring(envelope) end if string.len(envelope_bytes) > max_data_size then + local body = stanza:get_child_text("body") + if string.len(body) > 50 then + stanza_clone:maptags(function(el) + if el.name == "body" then + return nil + else + return el + end + end) + + body = string.gsub(string.gsub("\n" .. body, "\n>[^\n]*", ""), "^%s", "") + stanza_clone:body(body:sub(1, utf8.offset(body, 50)) .. "…") + envelope_bytes = tostring(envelope) + end + end + if string.len(envelope_bytes) > max_data_size then -- If still too big, get aggressive stanza_clone:maptags(function(el) if el.name == "body" or