From 636ecd1d038507e2856c527b2901436b8869ed42 Mon Sep 17 00:00:00 2001 From: diondiondion Date: Tue, 7 Oct 2025 14:50:40 +0200 Subject: [PATCH] Display quotes in email notifications (#36379) --- app/javascript/styles/entrypoints/mailer.scss | 42 +++++++++++++++++++ .../_nested_quote.html.haml | 17 ++++++++ .../notification_mailer/_status.html.haml | 21 +++------- .../notification_mailer/_status.text.erb | 4 ++ .../_status_content.html.haml | 15 +++++++ 5 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 app/views/notification_mailer/_nested_quote.html.haml create mode 100644 app/views/notification_mailer/_status_content.html.haml diff --git a/app/javascript/styles/entrypoints/mailer.scss b/app/javascript/styles/entrypoints/mailer.scss index 7d2a54afa..fcbbd66f4 100644 --- a/app/javascript/styles/entrypoints/mailer.scss +++ b/app/javascript/styles/entrypoints/mailer.scss @@ -88,6 +88,14 @@ table + p { padding: 24px; } +.email-inner-nested-card-td { + border-radius: 12px; + padding: 18px; + overflow: hidden; + background-color: #fff; + border: 1px solid #dfdee3; +} + // Account .email-account-banner-table { background-color: #f3f2f5; @@ -559,12 +567,29 @@ table + p { } } +.email-quote-header-img { + width: 34px; + + img { + width: 34px; + height: 34px; + border-radius: 8px; + overflow: hidden; + } +} + .email-status-header-text { padding-left: 16px; padding-right: 16px; vertical-align: middle; } +.email-quote-header-text { + padding-left: 14px; + padding-right: 14px; + vertical-align: middle; +} + .email-status-header-name { font-size: 16px; font-weight: 600; @@ -578,6 +603,19 @@ table + p { color: #746a89; } +.email-quote-header-name { + font-size: 14px; + font-weight: 600; + line-height: 18px; + color: #17063b; +} + +.email-quote-header-handle { + font-size: 13px; + line-height: 18px; + color: #746a89; +} + .email-status-content { padding-top: 24px; } @@ -589,6 +627,10 @@ table + p { } .email-status-prose { + .quote-inline { + display: none; + } + p { font-size: 14px; line-height: 20px; diff --git a/app/views/notification_mailer/_nested_quote.html.haml b/app/views/notification_mailer/_nested_quote.html.haml new file mode 100644 index 000000000..e66736399 --- /dev/null +++ b/app/views/notification_mailer/_nested_quote.html.haml @@ -0,0 +1,17 @@ +%table.email-w-full{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' } + %tr + %td.email-quote-header-img + = image_tag full_asset_url(status.account.avatar.url), alt: '', width: 34, height: 34 + %td.email-quote-header-text + %h2.email-quote-header-name + = display_name(status.account) + %p.email-quote-header-handle + @#{status.account.pretty_acct} + +%table.email-w-full{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' } + %tr + %td.email-status-content + = render 'status_content', status: status + + %p.email-status-footer + = link_to l(status.created_at.in_time_zone(time_zone.presence), format: :with_time_zone), web_url("@#{status.account.pretty_acct}/#{status.id}") diff --git a/app/views/notification_mailer/_status.html.haml b/app/views/notification_mailer/_status.html.haml index bf38dc9aa..064709e7d 100644 --- a/app/views/notification_mailer/_status.html.haml +++ b/app/views/notification_mailer/_status.html.haml @@ -11,21 +11,12 @@ %table.email-w-full{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' } %tr %td.email-status-content - .auto-dir - - if status.spoiler_text? - %p.email-status-spoiler - = status.spoiler_text - - .email-status-prose - = status_content_format(status) - - - if status.ordered_media_attachments.size.positive? - %p.email-status-media - - status.ordered_media_attachments.each do |a| - - if status.local? - = link_to full_asset_url(a.file.url(:original)), full_asset_url(a.file.url(:original)) - - else - = link_to a.remote_url, a.remote_url + = render 'status_content', status: status + - if status.local? && status.quote + %table.email-inner-card-table{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' } + %tr + %td.email-inner-nested-card-td + = render 'nested_quote', status: status.quote.quoted_status, time_zone: time_zone %p.email-status-footer = link_to l(status.created_at.in_time_zone(time_zone.presence), format: :with_time_zone), web_url("@#{status.account.pretty_acct}/#{status.id}") diff --git a/app/views/notification_mailer/_status.text.erb b/app/views/notification_mailer/_status.text.erb index e03e8346c..13711ee74 100644 --- a/app/views/notification_mailer/_status.text.erb +++ b/app/views/notification_mailer/_status.text.erb @@ -4,5 +4,9 @@ > <% end %> > <%= raw word_wrap(extract_status_plain_text(status), break_sequence: "\n> ") %> +<% if status.local? && status.quote %> +> +>> <%= raw word_wrap(extract_status_plain_text(status.quote.quoted_status), break_sequence: "\n>> ") %> +<% end %> <%= raw t('application_mailer.view')%> <%= web_url("@#{status.account.pretty_acct}/#{status.id}") %> diff --git a/app/views/notification_mailer/_status_content.html.haml b/app/views/notification_mailer/_status_content.html.haml new file mode 100644 index 000000000..f95ba8ccb --- /dev/null +++ b/app/views/notification_mailer/_status_content.html.haml @@ -0,0 +1,15 @@ +.auto-dir + - if status.spoiler_text? + %p.email-status-spoiler + = status.spoiler_text + + .email-status-prose + = status_content_format(status) + + - if status.ordered_media_attachments.size.positive? + %p.email-status-media + - status.ordered_media_attachments.each do |a| + - if status.local? + = link_to full_asset_url(a.file.url(:original)), full_asset_url(a.file.url(:original)) + - else + = link_to a.remote_url, a.remote_url