Merge branch 'feature/group-posts-in-timeline' of https://code.gab.com/gab/social/gab-social into develop

This commit is contained in:
Rob Colbert
2019-08-20 19:31:58 -04:00
7 changed files with 49 additions and 1 deletions

View File

@@ -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

View File

@@ -28,4 +28,12 @@ module GroupInteractions
end
end
def accounts_for_local_distribution
accounts.local
.joins(:user)
.where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago)
.where('users.id NOT IN (SELECT thing_id FROM settings WHERE thing_type = \'User\' AND var = \'group_in_home_feed\' AND value = \'--- false
\')')
end
end

View File

@@ -287,7 +287,13 @@ class Status < ApplicationRecord
end
def as_home_timeline(account)
where(account: [account] + account.following).where(visibility: [:public, :unlisted, :private])
query = where(account: [account] + account.following)
if account.user.allows_group_in_home_feed?
query = query.or(where(group: account.groups))
end
query.where(visibility: [:public, :unlisted, :private])
end
def as_group_timeline(group)

View File

@@ -213,6 +213,10 @@ class User < ApplicationRecord
@shows_application ||= settings.show_application
end
def allows_group_in_home_feed?
settings.group_in_home_feed
end
def token_for_app(a)
return nil if a.nil? || a.owner != self
Doorkeeper::AccessToken
@@ -270,6 +274,10 @@ class User < ApplicationRecord
setting_display_media == 'hide_all'
end
def force_regeneration!
Redis.current.set("account:#{account_id}:regeneration", true)
end
protected
def send_devise_notification(notification, *args)