parent
89ef448d3a
commit
d789304e19
3 changed files with 37 additions and 2 deletions
|
@ -78,6 +78,7 @@ class Status < ApplicationRecord
|
||||||
has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog, dependent: :destroy
|
has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog, dependent: :destroy
|
||||||
has_many :reblogged_by_accounts, through: :reblogs, class_name: 'Account', source: :account
|
has_many :reblogged_by_accounts, through: :reblogs, class_name: 'Account', source: :account
|
||||||
has_many :quotes, foreign_key: 'quote_of_id', class_name: 'Status', inverse_of: :quote
|
has_many :quotes, foreign_key: 'quote_of_id', class_name: 'Status', inverse_of: :quote
|
||||||
|
has_many :quoted_by_accounts, through: :quotes, class_name: 'Account', source: :account
|
||||||
has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread
|
has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread
|
||||||
has_many :mentions, dependent: :destroy, inverse_of: :status
|
has_many :mentions, dependent: :destroy, inverse_of: :status
|
||||||
has_many :mentioned_accounts, through: :mentions, source: :account, class_name: 'Account'
|
has_many :mentioned_accounts, through: :mentions, source: :account, class_name: 'Account'
|
||||||
|
|
|
@ -89,7 +89,7 @@ class FanOutOnWriteService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_about_update!
|
def notify_about_update!
|
||||||
@status.reblogged_by_accounts.merge(Account.local).select(:id).reorder(nil).find_in_batches do |accounts|
|
@status.reblogged_by_accounts.or(@status.quoted_by_accounts).merge(Account.local).select(:id).reorder(nil).find_in_batches do |accounts|
|
||||||
LocalNotificationWorker.push_bulk(accounts) do |account|
|
LocalNotificationWorker.push_bulk(accounts) do |account|
|
||||||
[account.id, @status.id, 'Status', 'update']
|
[account.id, @status.id, 'Status', 'update']
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
||||||
subject { described_class.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:last_active_at) { Time.now.utc }
|
let(:last_active_at) { Time.now.utc }
|
||||||
|
let(:visibility) { 'public' }
|
||||||
let(:searchability) { 'public' }
|
let(:searchability) { 'public' }
|
||||||
let(:dissubscribable) { false }
|
let(:dissubscribable) { false }
|
||||||
let(:status) { Fabricate(:status, account: alice, visibility: visibility, searchability: searchability, text: 'Hello @bob #hoge') }
|
let(:status) { Fabricate(:status, account: alice, visibility: visibility, searchability: searchability, text: 'Hello @bob #hoge') }
|
||||||
|
@ -20,6 +21,8 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
||||||
let!(:antenna) { nil }
|
let!(:antenna) { nil }
|
||||||
let!(:empty_antenna) { nil }
|
let!(:empty_antenna) { nil }
|
||||||
|
|
||||||
|
let(:custom_before) { false }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
tom.follow!(alice)
|
tom.follow!(alice)
|
||||||
|
@ -30,7 +33,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
||||||
|
|
||||||
allow(redis).to receive(:publish)
|
allow(redis).to receive(:publish)
|
||||||
|
|
||||||
subject.call(status)
|
subject.call(status) unless custom_before
|
||||||
end
|
end
|
||||||
|
|
||||||
def home_feed_of(account)
|
def home_feed_of(account)
|
||||||
|
@ -469,4 +472,35 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when updated status is already boosted or quoted' do
|
||||||
|
let(:custom_before) { true }
|
||||||
|
|
||||||
|
before do
|
||||||
|
ReblogService.new.call(bob, status)
|
||||||
|
PostStatusService.new.call(tom, text: "Hello QT #{ActivityPub::TagManager.instance.uri_for(status)}")
|
||||||
|
|
||||||
|
subject.call(status, update: true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'notified to boosted account' do
|
||||||
|
notification = Notification.find_by(account: bob, type: 'update')
|
||||||
|
|
||||||
|
expect(notification).to_not be_nil
|
||||||
|
expect(notification.activity_id).to eq status.id
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'notified to quoted account' do
|
||||||
|
notification = Notification.find_by(account: tom, type: 'update')
|
||||||
|
|
||||||
|
expect(notification).to_not be_nil
|
||||||
|
expect(notification.activity_id).to eq status.id
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'notified not to non-boosted account' do
|
||||||
|
notification = Notification.find_by(account: ohagi, type: 'update')
|
||||||
|
|
||||||
|
expect(notification).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue