Merge branch 'feature/group-posts-in-timeline' of https://code.gab.com/gab/social/gab-social into develop
This commit is contained in:
commit
ad07cde21b
|
@ -20,6 +20,11 @@ class Api::V1::Groups::AccountsController < Api::BaseController
|
||||||
authorize @group, :join?
|
authorize @group, :join?
|
||||||
|
|
||||||
@group.accounts << current_account
|
@group.accounts << current_account
|
||||||
|
|
||||||
|
if current_user.allows_group_in_home_feed?
|
||||||
|
current_user.force_regeneration!
|
||||||
|
end
|
||||||
|
|
||||||
render json: @group, serializer: REST::GroupRelationshipSerializer, relationships: relationships
|
render json: @group, serializer: REST::GroupRelationshipSerializer, relationships: relationships
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,6 +40,11 @@ class Api::V1::Groups::AccountsController < Api::BaseController
|
||||||
authorize @group, :leave?
|
authorize @group, :leave?
|
||||||
|
|
||||||
GroupAccount.where(group: @group, account_id: current_account.id).destroy_all
|
GroupAccount.where(group: @group, account_id: current_account.id).destroy_all
|
||||||
|
|
||||||
|
if current_user.allows_group_in_home_feed?
|
||||||
|
current_user.force_regeneration!
|
||||||
|
end
|
||||||
|
|
||||||
render json: @group, serializer: REST::GroupRelationshipSerializer, relationships: relationships
|
render json: @group, serializer: REST::GroupRelationshipSerializer, relationships: relationships
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ class Settings::PreferencesController < Settings::BaseController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
user_settings.update(user_settings_params.to_h)
|
user_settings.update(user_settings_params.to_h)
|
||||||
|
current_user.force_regeneration!
|
||||||
|
|
||||||
if current_user.update(user_params)
|
if current_user.update(user_params)
|
||||||
I18n.locale = current_user.locale
|
I18n.locale = current_user.locale
|
||||||
|
|
|
@ -71,6 +71,9 @@ module AccountInteractions
|
||||||
has_many :following, -> { order('follows.id desc') }, through: :active_relationships, source: :target_account
|
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 :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
|
# Block relationships
|
||||||
has_many :block_relationships, class_name: 'Block', foreign_key: 'account_id', dependent: :destroy
|
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
|
has_many :blocking, -> { order('blocks.id desc') }, through: :block_relationships, source: :target_account
|
||||||
|
|
|
@ -28,4 +28,12 @@ module GroupInteractions
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
@ -287,7 +287,13 @@ class Status < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_home_timeline(account)
|
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
|
end
|
||||||
|
|
||||||
def as_group_timeline(group)
|
def as_group_timeline(group)
|
||||||
|
|
|
@ -213,6 +213,10 @@ class User < ApplicationRecord
|
||||||
@shows_application ||= settings.show_application
|
@shows_application ||= settings.show_application
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def allows_group_in_home_feed?
|
||||||
|
settings.group_in_home_feed
|
||||||
|
end
|
||||||
|
|
||||||
def token_for_app(a)
|
def token_for_app(a)
|
||||||
return nil if a.nil? || a.owner != self
|
return nil if a.nil? || a.owner != self
|
||||||
Doorkeeper::AccessToken
|
Doorkeeper::AccessToken
|
||||||
|
@ -270,6 +274,10 @@ class User < ApplicationRecord
|
||||||
setting_display_media == 'hide_all'
|
setting_display_media == 'hide_all'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def force_regeneration!
|
||||||
|
Redis.current.set("account:#{account_id}:regeneration", true)
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def send_devise_notification(notification, *args)
|
def send_devise_notification(notification, *args)
|
||||||
|
|
|
@ -46,6 +46,16 @@ class FanOutOnWriteService < BaseService
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def deliver_to_group_members(status)
|
||||||
|
Rails.logger.debug "Delivering status #{status.id} to group members #{status.group.id}"
|
||||||
|
|
||||||
|
status.group.accounts_for_local_distribution.select(:id).reorder(nil).find_in_batches do |members|
|
||||||
|
FeedInsertWorker.push_bulk(members) do |member|
|
||||||
|
[status.id, member.id, :home]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def deliver_to_lists(status)
|
def deliver_to_lists(status)
|
||||||
Rails.logger.debug "Delivering status #{status.id} to lists"
|
Rails.logger.debug "Delivering status #{status.id} to lists"
|
||||||
|
|
||||||
|
@ -62,6 +72,8 @@ class FanOutOnWriteService < BaseService
|
||||||
Rails.logger.debug "Delivering status #{status.id} to group"
|
Rails.logger.debug "Delivering status #{status.id} to group"
|
||||||
|
|
||||||
Redis.current.publish("timeline:group:#{status.group_id}", @payload)
|
Redis.current.publish("timeline:group:#{status.group_id}", @payload)
|
||||||
|
|
||||||
|
deliver_to_group_members(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
def deliver_to_mentioned_followers(status)
|
def deliver_to_mentioned_followers(status)
|
||||||
|
|
Loading…
Reference in New Issue