Add missing mailer for quote notifications (#35652)

This commit is contained in:
Claire 2025-08-04 12:44:59 +02:00 committed by GitHub
parent f68bd21600
commit 80aadc55df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 66 additions and 1 deletions

View File

@ -6,7 +6,7 @@ class NotificationMailer < ApplicationMailer
:routing
before_action :process_params
with_options only: %i(mention favourite reblog) do
with_options only: %i(mention favourite reblog quote) do
before_action :set_status
after_action :thread_by_conversation!
end
@ -27,6 +27,14 @@ class NotificationMailer < ApplicationMailer
end
end
def quote
return if @status.blank?
locale_for_account(@me) do
mail subject: default_i18n_subject(name: @status.account.acct)
end
end
def follow
locale_for_account(@me) do
mail subject: default_i18n_subject(name: @account.acct)

View File

@ -30,6 +30,7 @@ class Notification < ApplicationRecord
'FollowRequest' => :follow_request,
'Favourite' => :favourite,
'Poll' => :poll,
'Quote' => :quote,
}.freeze
# Please update app/javascript/api_types/notification.ts if you change this

View File

@ -43,6 +43,7 @@ class UserSettings
setting :reblog, default: false
setting :favourite, default: false
setting :mention, default: true
setting :quote, default: true
setting :follow_request, default: true
setting :report, default: true
setting :pending_account, default: true

View File

@ -0,0 +1,16 @@
= content_for :heading do
= render 'application/mailer/heading',
image_url: frontend_asset_url('images/mailer-new/heading/boost.png'),
subtitle: t('notification_mailer.quote.body', name: @status.account.pretty_acct),
title: t('notification_mailer.quote.title')
%table.email-w-full{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' }
%tr
%td.email-body-padding-td
%table.email-inner-card-table{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' }
%tr
%td.email-inner-card-td
= render 'status', status: @status, time_zone: @me.user_time_zone
%table.email-w-full{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' }
%tr
%td.email-padding-top-24
= render 'application/mailer/button', text: t('notification_mailer.mention.action'), url: web_url("@#{@status.account.pretty_acct}/#{@status.id}")

View File

@ -0,0 +1,5 @@
<%= raw t('application_mailer.salutation', name: display_name(@me)) %>
<%= raw t('notification_mailer.quote.body', name: @status.account.pretty_acct) %>
<%= render 'status', status: @status %>

View File

@ -18,6 +18,7 @@
= ff.input :'notification_emails.reblog', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.reblog')
= ff.input :'notification_emails.favourite', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.favourite')
= ff.input :'notification_emails.mention', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.mention')
= ff.input :'notification_emails.quote', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.quote')
.fields-group
= ff.input :always_send_emails, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_always_send_emails'), hint: I18n.t('simple_form.hints.defaults.setting_always_send_emails')

View File

@ -1687,6 +1687,10 @@ en:
title: New mention
poll:
subject: A poll by %{name} has ended
quote:
body: 'Your post was quoted by %{name}:'
subject: "%{name} quoted your post"
title: New quote
reblog:
body: 'Your post was boosted by %{name}:'
subject: "%{name} boosted your post"

View File

@ -329,6 +329,7 @@ en:
follow_request: Someone requested to follow you
mention: Someone mentioned you
pending_account: New account needs review
quote: Someone quoted you
reblog: Someone boosted your post
report: New report is submitted
software_updates:

View File

@ -51,6 +51,27 @@ RSpec.describe NotificationMailer do
it_behaves_like 'delivery without status'
end
describe 'quote' do
let(:quote) { Fabricate(:quote, state: :accepted, status: foreign_status, quoted_status: own_status) }
let(:notification) { Notification.create!(account: receiver.account, activity: quote) }
let(:mail) { prepared_mailer_for(own_status.account).quote }
it_behaves_like 'localized subject', 'notification_mailer.quote.subject', name: 'bob'
it 'renders the email' do
expect(mail)
.to be_present
.and(have_subject('bob quoted your post'))
.and(have_body_text('Your post was quoted by bob'))
.and(have_body_text('The body of the foreign status'))
.and have_thread_headers
.and have_standard_headers('quote').for(receiver)
end
it_behaves_like 'delivery to non functional user'
it_behaves_like 'delivery without status'
end
describe 'follow' do
let(:follow) { sender.follow!(receiver.account) }
let(:notification) { Notification.create!(account: receiver.account, activity: follow) }

View File

@ -33,6 +33,12 @@ class NotificationMailerPreview < ActionMailer::Preview
mailer_for(activity.reblog.account, activity).reblog
end
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/quote
def quote
activity = Quote.first
mailer_for(activity.quoted_account, activity).quote
end
private
def mailer_for(account, activity)

View File

@ -29,6 +29,7 @@ RSpec.describe 'API Web Push Subscriptions' do
mention: false,
poll: true,
status: false,
quote: true,
},
},
}