Merge branch 'kb_development' into kb_migration
This commit is contained in:
commit
751b603e12
17 changed files with 341 additions and 44 deletions
|
@ -17,6 +17,7 @@ class Api::V1::Antennas::KeywordsController < Api::BaseController
|
|||
new_keywords = @antenna.keywords || []
|
||||
keywords.each do |keyword|
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.duplicate_keyword') if new_keywords.include?(keyword)
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.too_short_keyword') if keyword.length < 2
|
||||
|
||||
new_keywords << keyword
|
||||
end
|
||||
|
|
|
@ -48,8 +48,6 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
|
||||
def create_status
|
||||
return reject_payload! if unsupported_object_type? || non_matching_uri_hosts?(@account.uri, object_uri) || tombstone_exists? || !related_to_local_activity?
|
||||
return reject_payload! if (reply_to_local? || reply_to_local_account?) && reject_reply_to_local?
|
||||
return reject_payload! if (!reply_to_local_account_following? || !reply_to_local_status_following?) && reject_reply_exclude_followers?
|
||||
|
||||
with_redis_lock("create:#{object_uri}") do
|
||||
return if delete_arrived_first?(object_uri) || poll_vote?
|
||||
|
@ -63,7 +61,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
end
|
||||
end
|
||||
|
||||
@status
|
||||
@status || reject_payload!
|
||||
end
|
||||
|
||||
def audience_to
|
||||
|
@ -90,7 +88,9 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
process_tags
|
||||
process_audience
|
||||
|
||||
return unless valid_status?
|
||||
return nil unless valid_status?
|
||||
return nil if (reply_to_local? || reply_to_local_account? || reply_to_local_from_tags?) && reject_reply_to_local?
|
||||
return nil if (!reply_to_local_account_following? || !reply_to_local_status_following? || !reply_to_local_from_tags_following?) && reject_reply_exclude_followers?
|
||||
|
||||
ApplicationRecord.transaction do
|
||||
@status = Status.create!(@params)
|
||||
|
@ -148,14 +148,6 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
!Admin::NgWord.reject?("#{@params[:spoiler_text]}\n#{@params[:text]}") && !Admin::NgWord.hashtag_reject?(@tags.size)
|
||||
end
|
||||
|
||||
def reply_to_local_account?
|
||||
accounts_in_audience.any?(&:local?)
|
||||
end
|
||||
|
||||
def reply_to_local_account_following?
|
||||
!reply_to_local_account? || accounts_in_audience.none? { |account| account.local? && !account.following?(@account) }
|
||||
end
|
||||
|
||||
def accounts_in_audience
|
||||
return @accounts_in_audience if @accounts_in_audience
|
||||
|
||||
|
@ -420,6 +412,22 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
@skip_download ||= DomainBlock.reject_media?(@account.domain)
|
||||
end
|
||||
|
||||
def reply_to_local_account?
|
||||
accounts_in_audience.any?(&:local?)
|
||||
end
|
||||
|
||||
def reply_to_local_account_following?
|
||||
!reply_to_local_account? || accounts_in_audience.none? { |account| account.local? && !account.following?(@account) }
|
||||
end
|
||||
|
||||
def reply_to_local_from_tags?
|
||||
(@mentions.present? && @mentions.any? { |m| m.account.local? })
|
||||
end
|
||||
|
||||
def reply_to_local_from_tags_following?
|
||||
(@mentions.present? && @mentions.none? { |m| m.account.local? && !m.account.following?(@account) })
|
||||
end
|
||||
|
||||
def reply_to_local?
|
||||
!replied_to_status.nil? && replied_to_status.account.local?
|
||||
end
|
||||
|
|
|
@ -54,7 +54,7 @@ class SearchQueryTransformer < Parslet::Transform
|
|||
|
||||
def to_query
|
||||
# { multi_match: { type: 'most_fields', query: @term, fields: ['text', 'text.stemmed'], operator: 'and' } }
|
||||
{ match_phrase: { text: { query: @phrase } } }
|
||||
{ match_phrase: { text: { query: @term } } }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ class DeliveryAntennaService
|
|||
def delivery!
|
||||
tag_ids = @status.tags.pluck(:id)
|
||||
domain = @account.domain || Rails.configuration.x.local_domain
|
||||
follower_ids = @status.unlisted_visibility? ? @status.account.followers.pluck(:id) : []
|
||||
|
||||
antennas = Antenna.availables
|
||||
antennas = antennas.left_joins(:antenna_domains).where(any_domains: true).or(Antenna.left_joins(:antenna_domains).where(antenna_domains: { name: domain }))
|
||||
|
@ -32,7 +33,7 @@ class DeliveryAntennaService
|
|||
antennas = antennas.left_joins(:antenna_tags).where(any_tags: true).or(Antenna.left_joins(:antenna_tags).where(antenna_tags: { tag_id: tag_ids }))
|
||||
|
||||
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: @status.account.followers) if [:public, :public_unlisted, :login, :limited].exclude?(@status.visibility.to_sym)
|
||||
antennas = antennas.where(account: @status.account.followers) if [:public, :public_unlisted, :login, :limited].exclude?(@status.visibility.to_sym) && !@status.public_searchability?
|
||||
antennas = antennas.where(account: @status.mentioned_accounts) if @status.visibility.to_sym == :limited
|
||||
antennas = antennas.where(with_media_only: false) unless @status.with_media?
|
||||
antennas = antennas.where(ignore_reblog: false) if @status.reblog?
|
||||
|
@ -49,6 +50,8 @@ class DeliveryAntennaService
|
|||
next if antenna.exclude_accounts&.include?(@status.account_id)
|
||||
next if antenna.exclude_domains&.include?(domain)
|
||||
next if antenna.exclude_tags&.any? { |tag_id| tag_ids.include?(tag_id) }
|
||||
next if @status.unlisted_visibility? && !@status.public_searchability? && follower_ids.exclude?(antenna.account_id)
|
||||
next if @status.unlisted_visibility? && @status.public_searchability? && follower_ids.exclude?(antenna.account_id) && antenna.any_keywords && antenna.any_tags
|
||||
|
||||
collection.push(antenna)
|
||||
end
|
||||
|
@ -84,10 +87,13 @@ class DeliveryAntennaService
|
|||
@stl_home = stl_home
|
||||
@home_account_ids = []
|
||||
@list_ids = []
|
||||
@antenna_timeline_ids = []
|
||||
end
|
||||
|
||||
def push(antenna)
|
||||
if antenna.list_id.zero?
|
||||
if !antenna.insert_feeds?
|
||||
@antenna_timeline_ids << { id: antenna.id, antenna_id: antenna.id }
|
||||
elsif antenna.list_id.zero?
|
||||
@home_account_ids << { id: antenna.account_id, antenna_id: antenna.id } if @home_account_ids.none? { |id| id[:id] == antenna.account_id }
|
||||
elsif @list_ids.none? { |id| id[:id] == antenna.list_id }
|
||||
@list_ids << { id: antenna.list_id, antenna_id: antenna.id }
|
||||
|
@ -97,6 +103,7 @@ class DeliveryAntennaService
|
|||
def deliver!
|
||||
lists = @list_ids
|
||||
homes = @home_account_ids
|
||||
timelines = @antenna_timeline_ids
|
||||
|
||||
if lists.any?
|
||||
FeedInsertWorker.push_bulk(lists) do |list|
|
||||
|
@ -104,10 +111,16 @@ class DeliveryAntennaService
|
|||
end
|
||||
end
|
||||
|
||||
return unless homes.any?
|
||||
if homes.any?
|
||||
FeedInsertWorker.push_bulk(homes) do |home|
|
||||
[@status.id, home[:id], 'home', { 'update' => @update, 'antenna_id' => home[:antenna_id] }]
|
||||
end
|
||||
end
|
||||
|
||||
FeedInsertWorker.push_bulk(homes) do |home|
|
||||
[@status.id, home[:id], 'home', { 'update' => @update, 'antenna_id' => home[:antenna_id] }]
|
||||
return unless timelines.any?
|
||||
|
||||
FeedInsertWorker.push_bulk(timelines) do |antenna|
|
||||
[@status.id, antenna[:id], 'antenna', { 'update' => @update }]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,15 +38,6 @@
|
|||
|
||||
= yield :header_tags
|
||||
|
||||
%script{ 'src' => "https://www.googletagmanager.com/gtag/js?id=AW-11130587137", 'async' => true }
|
||||
|
||||
:javascript
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'AW-11130587137');
|
||||
|
||||
%body{ class: body_classes }
|
||||
= content_for?(:content) ? yield(:content) : yield
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@ class FeedInsertWorker
|
|||
when :list
|
||||
@list = List.find(id)
|
||||
@follower = @list.account
|
||||
when :antenna
|
||||
@antenna = Antenna.find(id)
|
||||
@follower = @antenna.account
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -40,7 +43,7 @@ class FeedInsertWorker
|
|||
|
||||
def feed_filtered?
|
||||
case @type
|
||||
when :home
|
||||
when :home, :antenna
|
||||
FeedManager.instance.filter?(:home, @status, @follower)
|
||||
when :tags
|
||||
FeedManager.instance.filter?(:tags, @status, @follower)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue