mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 18:01:05 +00:00
Add missing mailer for quote notifications (#35652)
This commit is contained in:
parent
f68bd21600
commit
80aadc55df
|
@ -6,7 +6,7 @@ class NotificationMailer < ApplicationMailer
|
||||||
:routing
|
:routing
|
||||||
|
|
||||||
before_action :process_params
|
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
|
before_action :set_status
|
||||||
after_action :thread_by_conversation!
|
after_action :thread_by_conversation!
|
||||||
end
|
end
|
||||||
|
@ -27,6 +27,14 @@ class NotificationMailer < ApplicationMailer
|
||||||
end
|
end
|
||||||
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
|
def follow
|
||||||
locale_for_account(@me) do
|
locale_for_account(@me) do
|
||||||
mail subject: default_i18n_subject(name: @account.acct)
|
mail subject: default_i18n_subject(name: @account.acct)
|
||||||
|
|
|
@ -30,6 +30,7 @@ class Notification < ApplicationRecord
|
||||||
'FollowRequest' => :follow_request,
|
'FollowRequest' => :follow_request,
|
||||||
'Favourite' => :favourite,
|
'Favourite' => :favourite,
|
||||||
'Poll' => :poll,
|
'Poll' => :poll,
|
||||||
|
'Quote' => :quote,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
# Please update app/javascript/api_types/notification.ts if you change this
|
# Please update app/javascript/api_types/notification.ts if you change this
|
||||||
|
|
|
@ -43,6 +43,7 @@ class UserSettings
|
||||||
setting :reblog, default: false
|
setting :reblog, default: false
|
||||||
setting :favourite, default: false
|
setting :favourite, default: false
|
||||||
setting :mention, default: true
|
setting :mention, default: true
|
||||||
|
setting :quote, default: true
|
||||||
setting :follow_request, default: true
|
setting :follow_request, default: true
|
||||||
setting :report, default: true
|
setting :report, default: true
|
||||||
setting :pending_account, default: true
|
setting :pending_account, default: true
|
||||||
|
|
16
app/views/notification_mailer/quote.html.haml
Normal file
16
app/views/notification_mailer/quote.html.haml
Normal 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}")
|
5
app/views/notification_mailer/quote.text.erb
Normal file
5
app/views/notification_mailer/quote.text.erb
Normal 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 %>
|
|
@ -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.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.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.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
|
.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')
|
= 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')
|
||||||
|
|
|
@ -1687,6 +1687,10 @@ en:
|
||||||
title: New mention
|
title: New mention
|
||||||
poll:
|
poll:
|
||||||
subject: A poll by %{name} has ended
|
subject: A poll by %{name} has ended
|
||||||
|
quote:
|
||||||
|
body: 'Your post was quoted by %{name}:'
|
||||||
|
subject: "%{name} quoted your post"
|
||||||
|
title: New quote
|
||||||
reblog:
|
reblog:
|
||||||
body: 'Your post was boosted by %{name}:'
|
body: 'Your post was boosted by %{name}:'
|
||||||
subject: "%{name} boosted your post"
|
subject: "%{name} boosted your post"
|
||||||
|
|
|
@ -329,6 +329,7 @@ en:
|
||||||
follow_request: Someone requested to follow you
|
follow_request: Someone requested to follow you
|
||||||
mention: Someone mentioned you
|
mention: Someone mentioned you
|
||||||
pending_account: New account needs review
|
pending_account: New account needs review
|
||||||
|
quote: Someone quoted you
|
||||||
reblog: Someone boosted your post
|
reblog: Someone boosted your post
|
||||||
report: New report is submitted
|
report: New report is submitted
|
||||||
software_updates:
|
software_updates:
|
||||||
|
|
|
@ -51,6 +51,27 @@ RSpec.describe NotificationMailer do
|
||||||
it_behaves_like 'delivery without status'
|
it_behaves_like 'delivery without status'
|
||||||
end
|
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
|
describe 'follow' do
|
||||||
let(:follow) { sender.follow!(receiver.account) }
|
let(:follow) { sender.follow!(receiver.account) }
|
||||||
let(:notification) { Notification.create!(account: receiver.account, activity: follow) }
|
let(:notification) { Notification.create!(account: receiver.account, activity: follow) }
|
||||||
|
|
|
@ -33,6 +33,12 @@ class NotificationMailerPreview < ActionMailer::Preview
|
||||||
mailer_for(activity.reblog.account, activity).reblog
|
mailer_for(activity.reblog.account, activity).reblog
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
def mailer_for(account, activity)
|
def mailer_for(account, activity)
|
||||||
|
|
|
@ -29,6 +29,7 @@ RSpec.describe 'API Web Push Subscriptions' do
|
||||||
mention: false,
|
mention: false,
|
||||||
poll: true,
|
poll: true,
|
||||||
status: false,
|
status: false,
|
||||||
|
quote: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user