diff --git a/Syncer.js b/Syncer.js index 35803fe..6ecc501 100644 --- a/Syncer.js +++ b/Syncer.js @@ -632,7 +632,7 @@ class Syncer let upd = { body_text: obj.text||'', body_html: obj.html, - body_html_text: obj.html.replace(/]*>.*<\/style\s*>|<\/?[^>]*>/g, ''), + body_html_text: obj.html.replace(/]*>[\s\S]*?<\/style\s*>|<\/?[^>]*>/g, ''), }; await SQL.update( this.pg, 'messages m', { diff --git a/database/db.sql b/database/db.sql index 532df31..ce4ada8 100644 --- a/database/db.sql +++ b/database/db.sql @@ -81,8 +81,8 @@ begin coalesce(msg.props->>'to', '') || ' ' || coalesce(msg.props->>'cc', '') || ' ' || coalesce(msg.props->>'bcc', '') || ' ' || - (select string_agg((a->>'name') || ' ' || (a->>'mimetype') || ' ' || (a->>'size'), ' ') - from jsonb_array_values(coalesce(msg.props->'attachments', '[]'::jsonb)) as t (a)) || ' ' || + coalesce((select string_agg((a->>'name') || ' ' || (a->>'mimetype') || ' ' || (a->>'size'), ' ') + from jsonb_array_elements(coalesce(msg.props->'attachments', '[]'::jsonb)) as t (a)), '') || ' ' || msg.subject, '\W+', ' ', 'g' )), 'A')