Add list exclusive property stl support
This commit is contained in:
parent
edb2a5dcf3
commit
f59eb4c6d3
6 changed files with 19 additions and 12 deletions
|
@ -94,6 +94,7 @@ Metrics/BlockNesting:
|
||||||
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricscyclomaticcomplexity
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricscyclomaticcomplexity
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
- 'app/lib/feed_manager.rb'
|
||||||
- 'app/policies/status_policy.rb'
|
- 'app/policies/status_policy.rb'
|
||||||
- 'app/services/activitypub/process_account_service.rb'
|
- 'app/services/activitypub/process_account_service.rb'
|
||||||
- 'app/services/post_status_service.rb'
|
- 'app/services/post_status_service.rb'
|
||||||
|
|
|
@ -209,7 +209,7 @@ class ListTimeline extends PureComponent {
|
||||||
<div className='setting-toggle'>
|
<div className='setting-toggle'>
|
||||||
<Toggle id={`list-${id}-exclusive`} defaultChecked={isExclusive} onChange={this.onExclusiveToggle} />
|
<Toggle id={`list-${id}-exclusive`} defaultChecked={isExclusive} onChange={this.onExclusiveToggle} />
|
||||||
<label htmlFor={`list-${id}-exclusive`} className='setting-toggle__label'>
|
<label htmlFor={`list-${id}-exclusive`} className='setting-toggle__label'>
|
||||||
<FormattedMessage id='lists.exclusive' defaultMessage='Hide these posts from home' />
|
<FormattedMessage id='lists.exclusive' defaultMessage='Hide these posts from home or STL' />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -365,7 +365,7 @@
|
||||||
"lists.delete": "Delete list",
|
"lists.delete": "Delete list",
|
||||||
"lists.edit": "Edit list",
|
"lists.edit": "Edit list",
|
||||||
"lists.edit.submit": "Change title",
|
"lists.edit.submit": "Change title",
|
||||||
"lists.exclusive": "Hide these posts from home",
|
"lists.exclusive": "Hide these posts from home or STL",
|
||||||
"lists.new.create": "Add list",
|
"lists.new.create": "Add list",
|
||||||
"lists.new.title_placeholder": "New list title",
|
"lists.new.title_placeholder": "New list title",
|
||||||
"lists.replies_policy.followed": "Any followed user",
|
"lists.replies_policy.followed": "Any followed user",
|
||||||
|
|
|
@ -37,12 +37,12 @@ class FeedManager
|
||||||
# @param [Status] status
|
# @param [Status] status
|
||||||
# @param [Account|List] receiver
|
# @param [Account|List] receiver
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def filter?(timeline_type, status, receiver)
|
def filter?(timeline_type, status, receiver, stl_home = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||||
case timeline_type
|
case timeline_type
|
||||||
when :home
|
when :home
|
||||||
filter_from_home?(status, receiver.id, build_crutches(receiver.id, [status]), :home)
|
filter_from_home?(status, receiver.id, build_crutches(receiver.id, [status]), :home)
|
||||||
when :list
|
when :list
|
||||||
filter_from_list?(status, receiver) || filter_from_home?(status, receiver.account_id, build_crutches(receiver.account_id, [status]), :list)
|
filter_from_list?(status, receiver) || filter_from_home?(status, receiver.account_id, build_crutches(receiver.account_id, [status]), :list, stl_home)
|
||||||
when :mentions
|
when :mentions
|
||||||
filter_from_mentions?(status, receiver.id)
|
filter_from_mentions?(status, receiver.id)
|
||||||
when :tags
|
when :tags
|
||||||
|
@ -351,10 +351,10 @@ class FeedManager
|
||||||
# @param [Integer] receiver_id
|
# @param [Integer] receiver_id
|
||||||
# @param [Hash] crutches
|
# @param [Hash] crutches
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def filter_from_home?(status, receiver_id, crutches, timeline_type = :home)
|
def filter_from_home?(status, receiver_id, crutches, timeline_type = :home, stl_home = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||||
return false if receiver_id == status.account_id
|
return false if receiver_id == status.account_id
|
||||||
return true if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)
|
return true if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)
|
||||||
return true if timeline_type != :list && crutches[:exclusive_list_users][status.account_id].present?
|
return true if (timeline_type != :list || stl_home) && crutches[:exclusive_list_users][status.account_id].present?
|
||||||
return true if crutches[:languages][status.account_id].present? && status.language.present? && !crutches[:languages][status.account_id].include?(status.language)
|
return true if crutches[:languages][status.account_id].present? && status.language.present? && !crutches[:languages][status.account_id].include?(status.language)
|
||||||
|
|
||||||
check_for_blocks = crutches[:active_mentions][status.id] || []
|
check_for_blocks = crutches[:active_mentions][status.id] || []
|
||||||
|
|
|
@ -121,9 +121,10 @@ class FanOutOnWriteService < BaseService
|
||||||
antennas = Antenna.available_stls
|
antennas = Antenna.available_stls
|
||||||
antennas = antennas.where(account_id: Account.without_suspended.joins(:user).select('accounts.id').where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago))
|
antennas = antennas.where(account_id: Account.without_suspended.joins(:user).select('accounts.id').where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago))
|
||||||
|
|
||||||
antennas = antennas.where(account: @account.followers).or(antennas.where(account: @account)).where.not(list_id: 0) if !@account.domain.nil? || @status.reblog? || [:public, :public_unlisted, :login].exclude?(@status.visibility.to_sym)
|
home_post = !@account.domain.nil? || @status.reblog? || [:public, :public_unlisted, :login].exclude?(@status.visibility.to_sym)
|
||||||
|
antennas = antennas.where(account: @account.followers).or(antennas.where(account: @account)).where.not(list_id: 0) if home_post
|
||||||
|
|
||||||
collection = AntennaCollection.new(@status, @options[:update])
|
collection = AntennaCollection.new(@status, @options[:update], home_post)
|
||||||
|
|
||||||
antennas.in_batches do |ans|
|
antennas.in_batches do |ans|
|
||||||
ans.each do |antenna|
|
ans.each do |antenna|
|
||||||
|
@ -155,7 +156,7 @@ class FanOutOnWriteService < BaseService
|
||||||
|
|
||||||
antennas = antennas.where(account_id: Account.without_suspended.joins(:user).select('accounts.id').where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago))
|
antennas = antennas.where(account_id: Account.without_suspended.joins(:user).select('accounts.id').where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago))
|
||||||
|
|
||||||
collection = AntennaCollection.new(@status, @options[:update])
|
collection = AntennaCollection.new(@status, @options[:update], false)
|
||||||
|
|
||||||
antennas.in_batches do |ans|
|
antennas.in_batches do |ans|
|
||||||
ans.each do |antenna|
|
ans.each do |antenna|
|
||||||
|
@ -242,9 +243,10 @@ class FanOutOnWriteService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
class AntennaCollection
|
class AntennaCollection
|
||||||
def initialize(status, update)
|
def initialize(status, update, stl_home = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||||
@status = status
|
@status = status
|
||||||
@update = update
|
@update = update
|
||||||
|
@stl_home = stl_home
|
||||||
@home_account_ids = []
|
@home_account_ids = []
|
||||||
@list_ids = []
|
@list_ids = []
|
||||||
end
|
end
|
||||||
|
@ -263,7 +265,7 @@ class FanOutOnWriteService < BaseService
|
||||||
|
|
||||||
if lists.any?
|
if lists.any?
|
||||||
FeedInsertWorker.push_bulk(lists) do |list|
|
FeedInsertWorker.push_bulk(lists) do |list|
|
||||||
[@status.id, list, 'list', { 'update' => @update }]
|
[@status.id, list, 'list', { 'update' => @update, 'stl_home' => @stl_home || false }]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class FeedInsertWorker
|
||||||
when :tags
|
when :tags
|
||||||
FeedManager.instance.filter?(:tags, @status, @follower)
|
FeedManager.instance.filter?(:tags, @status, @follower)
|
||||||
when :list
|
when :list
|
||||||
FeedManager.instance.filter?(:list, @status, @list)
|
FeedManager.instance.filter?(:list, @status, @list, stl_home?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -74,4 +74,8 @@ class FeedInsertWorker
|
||||||
def update?
|
def update?
|
||||||
@options[:update]
|
@options[:update]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stl_home?
|
||||||
|
@options[:stl_home]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue