From 2f88e910b66d43e68c59dda3901914ddfe6934d1 Mon Sep 17 00:00:00 2001 From: noellabo Date: Sun, 20 Sep 2020 20:32:31 +0900 Subject: [PATCH] Eliminate duplication and provide status notifications outside of feed to home --- app/models/notification.rb | 1 + app/workers/feed_insert_worker.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index 3bf9dd483..8d4f96f8f 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -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) } diff --git a/app/workers/feed_insert_worker.rb b/app/workers/feed_insert_worker.rb index b70c7e389..2f88ae484 100644 --- a/app/workers/feed_insert_worker.rb +++ b/app/workers/feed_insert_worker.rb @@ -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