Skip to content

Commit 15f9033

Browse files
committed
Add notifications when a reblogged status has been updated
1 parent aa45404 commit 15f9033

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

app/models/status.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class Status < ApplicationRecord
6262
has_many :favourites, inverse_of: :status, dependent: :destroy
6363
has_many :bookmarks, inverse_of: :status, dependent: :destroy
6464
has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog, dependent: :destroy
65+
has_many :reblogged_by_accounts, through: :reblogs, class_name: 'Account', foreign_key: 'account_id'
6566
has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread
6667
has_many :mentions, dependent: :destroy, inverse_of: :status
6768
has_many :active_mentions, -> { active }, class_name: 'Mention', inverse_of: :status

app/services/fan_out_on_write_service.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def check_race_condition!
3434
def fan_out_to_local_recipients!
3535
deliver_to_self!
3636
notify_mentioned_accounts!
37+
notify_about_update! if update?
3738

3839
case @status.visibility.to_sym
3940
when :public, :unlisted, :private
@@ -64,6 +65,14 @@ def notify_mentioned_accounts!
6465
end
6566
end
6667

68+
def notify_about_update!
69+
@status.reblogged_by_accounts.merge(Account.local).select(:id).reorder(nil).find_in_batches do |accounts|
70+
LocalNotificationWorker.push_bulk(accounts) do |account|
71+
[account.id, @status.id, 'Status', 'update']
72+
end
73+
end
74+
end
75+
6776
def deliver_to_all_followers!
6877
@account.followers_for_local_distribution.select(:id).reorder(nil).find_in_batches do |followers|
6978
FeedInsertWorker.push_bulk(followers) do |follower|

0 commit comments

Comments
 (0)