Fix missing status_reference to push notification

This commit is contained in:
noellabo 2022-04-20 16:11:06 +09:00
parent 913cf3520a
commit 57ddd35698
6 changed files with 26 additions and 4 deletions

View file

@ -27,6 +27,7 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController
poll: alerts_enabled,
status: alerts_enabled,
emoji_reaction: alerts_enabled,
status_reference: alerts_enabled,
},
}
@ -62,6 +63,6 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController
end
def data_params
@data_params ||= params.require(:data).permit(:policy, alerts: [:follow, :follow_request, :favourite, :reblog, :mention, :poll, :status, :emoji_reaction])
@data_params ||= params.require(:data).permit(:policy, alerts: [:follow, :follow_request, :favourite, :reblog, :mention, :poll, :status, :emoji_reaction, :status_reference])
end
end

View file

@ -13,6 +13,7 @@ const initialState = Immutable.Map({
poll: false,
status: false,
emoji_reaction: false,
status_reference: false,
}),
isSubscribed: false,
browserSupport: false,

View file

@ -22,6 +22,7 @@ filenames.forEach(filename => {
'notification.status': full['notification.status'] || '',
'notification.poll': full['notification.poll'] || '',
'notification.emoji_reaction': full['notification.emoji_reaction'] || '',
'notification.status_reference': full['notification.status_reference'] || '',
'status.show_more': full['status.show_more'] || '',
'status.reblog': full['status.reblog'] || '',

View file

@ -38,6 +38,7 @@ describe Api::V1::Push::SubscriptionsController do
poll: true,
status: false,
emoji_reaction: false,
status_reference: false,
}
}
}.with_indifferent_access
@ -75,7 +76,7 @@ describe Api::V1::Push::SubscriptionsController do
expect(push_subscription.data['policy']).to eq(alerts_payload[:data][:policy])
%w(follow follow_request favourite reblog mention poll status emoji_reaction).each do |type|
%w(follow follow_request favourite reblog mention poll status emoji_reaction status_reference).each do |type|
expect(push_subscription.data['alerts'][type]).to eq(alerts_payload[:data][:alerts][type.to_sym].to_s)
end
end

View file

@ -33,6 +33,7 @@ describe Api::Web::PushSubscriptionsController do
poll: true,
status: false,
emoji_reaction: false,
status_reference: false,
}
}
}
@ -67,7 +68,7 @@ describe Api::Web::PushSubscriptionsController do
expect(push_subscription.data['policy']).to eq 'all'
%w(follow follow_request favourite reblog mention poll status emoji_reaction).each do |type|
%w(follow follow_request favourite reblog mention poll status emoji_reaction status_reference).each do |type|
expect(push_subscription.data['alerts'][type]).to eq(alerts_payload[:data][:alerts][type.to_sym].to_s)
end
end
@ -90,7 +91,7 @@ describe Api::Web::PushSubscriptionsController do
expect(push_subscription.data['policy']).to eq 'all'
%w(follow follow_request favourite reblog mention poll status emoji_reaction).each do |type|
%w(follow follow_request favourite reblog mention poll status emoji_reaction status_reference).each do |type|
expect(push_subscription.data['alerts'][type]).to eq(alerts_payload[:data][:alerts][type.to_sym].to_s)
end
end

View file

@ -119,6 +119,23 @@ RSpec.describe NotificationMailer, type: :mailer do
end
end
describe "status_reference" do
let(:status_reference) { StatusReference.create!(status: foreign_status, target_status: own_status) }
let(:mail) { NotificationMailer.status_reference(own_status.account, Notification.create!(account: receiver.account, activity: status_reference)) }
include_examples 'localized subject', 'notification_mailer.status_reference.subject', name: 'bob'
it "renders the headers" do
expect(mail.subject).to eq("bob referenced your post")
expect(mail.to).to eq([receiver.email])
end
it "renders the body" do
expect(mail.body.encoded).to match("Your post was referenced by bob")
expect(mail.body.encoded).to include 'The body of the foreign status'
end
end
describe 'digest' do
before do
mention = Fabricate(:mention, account: receiver.account, status: foreign_status)