From 53e95c4efcc0bbf480e9c416bc0673558aa8e20e Mon Sep 17 00:00:00 2001 From: abcang Date: Sun, 19 Nov 2017 23:32:48 +0900 Subject: Fix N+1 at notification (#5752) --- app/models/notification.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/models/notification.rb b/app/models/notification.rb index a3ffb1f45..976963528 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -24,7 +24,7 @@ class Notification < ApplicationRecord favourite: 'Favourite', }.freeze - STATUS_INCLUDES = [:account, :stream_entry, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, :media_attachments, :tags, mentions: :account]].freeze + STATUS_INCLUDES = [:account, :application, :stream_entry, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, :application, :media_attachments, :tags, mentions: :account]].freeze belongs_to :account belongs_to :from_account, class_name: 'Account' @@ -55,9 +55,11 @@ class Notification < ApplicationRecord def target_status case type when :reblog - activity&.reblog - when :favourite, :mention - activity&.status + status&.reblog + when :favourite + favourite&.status + when :mention + mention&.status end end -- cgit From 2bcc81700c586a543e849e222c640df89da7fcb0 Mon Sep 17 00:00:00 2001 From: abcang Date: Sun, 19 Nov 2017 23:33:15 +0900 Subject: Fix NoMethodError at ActivityPub::FetchRemoteStatusService (#5753) --- app/services/activitypub/fetch_remote_status_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/services/activitypub/fetch_remote_status_service.rb b/app/services/activitypub/fetch_remote_status_service.rb index 8d7b7a17c..8de9283de 100644 --- a/app/services/activitypub/fetch_remote_status_service.rb +++ b/app/services/activitypub/fetch_remote_status_service.rb @@ -18,7 +18,7 @@ class ActivityPub::FetchRemoteStatusService < BaseService actor = ActivityPub::TagManager.instance.uri_to_resource(actor_id, Account) actor = ActivityPub::FetchRemoteAccountService.new.call(actor_id, id: true) if actor.nil? || needs_update(actor) - return if actor.suspended? + return if actor.nil? || actor.suspended? ActivityPub::Activity.factory(activity_json, actor).perform end -- cgit