From 1f0f96415e74a9b8cb6aa43b9d71c09fd349b861 Mon Sep 17 00:00:00 2001 From: 2458773093 <2458773093@protonmail.com> Date: Tue, 20 Aug 2019 02:25:10 +0300 Subject: [PATCH] group posts in feed db builder --- app/models/concerns/account_interactions.rb | 3 +++ app/models/status.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/account_interactions.rb b/app/models/concerns/account_interactions.rb index ad2909d9..395c2079 100644 --- a/app/models/concerns/account_interactions.rb +++ b/app/models/concerns/account_interactions.rb @@ -71,6 +71,9 @@ module AccountInteractions has_many :following, -> { order('follows.id desc') }, through: :active_relationships, source: :target_account has_many :followers, -> { order('follows.id desc') }, through: :passive_relationships, source: :account + has_many :group_accounts, inverse_of: :account, dependent: :destroy, source: :account + has_many :groups, through: :group_accounts + # Block relationships has_many :block_relationships, class_name: 'Block', foreign_key: 'account_id', dependent: :destroy has_many :blocking, -> { order('blocks.id desc') }, through: :block_relationships, source: :target_account diff --git a/app/models/status.rb b/app/models/status.rb index 9c055116..940f82a7 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -283,7 +283,7 @@ class Status < ApplicationRecord end def as_home_timeline(account) - where(account: [account] + account.following).where(visibility: [:public, :unlisted, :private]) + where(account: [account] + account.following).or(where(group: account.groups)).where(visibility: [:public, :unlisted, :private]) end def as_group_timeline(group)