Eliminate duplication and provide status notifications outside of feed to home

This commit is contained in:
noellabo 2020-09-20 20:32:31 +09:00
parent 96258f2a86
commit 2f88e910b6
2 changed files with 2 additions and 1 deletions

View file

@ -57,6 +57,7 @@ class Notification < ApplicationRecord
belongs_to :poll, foreign_key: 'activity_id', optional: true
validates :type, inclusion: { in: TYPES }
validates :activity_id, uniqueness: { scope: [:account_id, :type] }, if: -> { type.to_sym == :status }
scope :without_suspended, -> { joins(:from_account).merge(Account.without_suspended) }

View file

@ -39,7 +39,7 @@ class FeedInsertWorker
end
def notify?
return false if @type != :home || @status.reblog? || (@status.reply? && @status.in_reply_to_account_id != @status.account_id)
return false if @status.reblog? || (@status.reply? && @status.in_reply_to_account_id != @status.account_id)
Follow.find_by(account: @follower, target_account: @status.account)&.notify?
end