Fix antennas some bugs
This commit is contained in:
parent
2eb5ffb9b3
commit
ac81f96777
5 changed files with 66 additions and 21 deletions
|
@ -34,7 +34,7 @@ class Antenna < ApplicationRecord
|
|||
scope :availables, -> { where(available: true) }
|
||||
|
||||
def enabled?
|
||||
available && !(any_keywords && any_domains && any_accounts && any_tags) && !expires?
|
||||
available && !expires? #&& !(any_keywords && any_domains && any_accounts && any_tags)
|
||||
end
|
||||
|
||||
def expires_in
|
||||
|
@ -99,11 +99,11 @@ class Antenna < ApplicationRecord
|
|||
|
||||
tag_names = raw.split(/\R/).filter { |r| r.present? }
|
||||
|
||||
antenna_tags.where(exclude: false).destroy_all!
|
||||
antenna_tags.where(exclude: false).destroy_all
|
||||
Tag.find_or_create_by_names(tag_names).each do |tag|
|
||||
antenna_tags.create!(tag: tag, exclude: false)
|
||||
end
|
||||
self[:any_tags] = !tag_names.any? && !exclude_tags&.any?
|
||||
self[:any_tags] = !tag_names.any?
|
||||
end
|
||||
|
||||
def exclude_tags_raw
|
||||
|
@ -115,11 +115,10 @@ class Antenna < ApplicationRecord
|
|||
|
||||
tag_names = raw.split(/\R/).filter { |r| r.present? }
|
||||
|
||||
antenna_tags.where(exclude: true).destroy_all!
|
||||
antenna_tags.where(exclude: true).destroy_all
|
||||
Tag.find_or_create_by_names(tag_names).each do |tag|
|
||||
antenna_tags.create!(tag: tag, exclude: true)
|
||||
end
|
||||
self[:any_tags] = !tag_names.any? && !tags&.any?
|
||||
end
|
||||
|
||||
def domains_raw
|
||||
|
@ -131,11 +130,11 @@ class Antenna < ApplicationRecord
|
|||
|
||||
domain_names = raw.split(/\R/).filter { |r| r.present? }
|
||||
|
||||
antenna_domains.where(exclude: false).destroy_all!
|
||||
antenna_domains.where(exclude: false).destroy_all
|
||||
domain_names.each do |domain|
|
||||
antenna_domains.create!(name: domain, exclude: false)
|
||||
end
|
||||
self[:any_domains] = !domain_names.any? && !exclude_domains&.any?
|
||||
self[:any_domains] = !domain_names.any?
|
||||
end
|
||||
|
||||
def exclude_domains_raw
|
||||
|
@ -147,11 +146,10 @@ class Antenna < ApplicationRecord
|
|||
|
||||
domain_names = raw.split(/\R/).filter { |r| r.present? }
|
||||
|
||||
antenna_domains.where(exclude: true).destroy_all!
|
||||
antenna_domains.where(exclude: true).destroy_all
|
||||
domain_names.each do |domain|
|
||||
antenna_domains.create!(name: domain, exclude: true)
|
||||
end
|
||||
self[:any_domains] = !domain_names.any? && !domains&.any?
|
||||
end
|
||||
|
||||
def accounts_raw
|
||||
|
@ -164,7 +162,7 @@ class Antenna < ApplicationRecord
|
|||
account_names = raw.split(/\R/).filter { |r| r.present? }
|
||||
|
||||
hit = false
|
||||
antenna_accounts.where(exclude: false).destroy_all!
|
||||
antenna_accounts.where(exclude: false).destroy_all
|
||||
account_names.each do |name|
|
||||
name = name[1..-1] if name.start_with?('@')
|
||||
username, domain = name.split('@')
|
||||
|
@ -174,7 +172,7 @@ class Antenna < ApplicationRecord
|
|||
hit = true
|
||||
end
|
||||
end
|
||||
self[:any_accounts] = !hit && !exclude_accounts&.any?
|
||||
self[:any_accounts] = !hit
|
||||
end
|
||||
|
||||
def exclude_accounts_raw
|
||||
|
@ -187,7 +185,7 @@ class Antenna < ApplicationRecord
|
|||
account_names = raw.split(/\R/).filter { |r| r.present? }
|
||||
|
||||
hit = false
|
||||
antenna_accounts.where(exclude: true).destroy_all!
|
||||
antenna_accounts.where(exclude: true).destroy_all
|
||||
account_names.each do |name|
|
||||
name = name[1..-1] if name.start_with?('@')
|
||||
username, domain = name.split('@')
|
||||
|
@ -197,7 +195,6 @@ class Antenna < ApplicationRecord
|
|||
hit = true
|
||||
end
|
||||
end
|
||||
self[:any_accounts] = !hit && !accounts&.any?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -119,16 +119,17 @@ class FanOutOnWriteService < BaseService
|
|||
def deliver_to_antennas!
|
||||
lists = []
|
||||
antennas = Antenna.availables
|
||||
p '=========================== DEBUG A ' + antennas.size.to_s
|
||||
antennas = antennas.merge!(Antenna.where(any_accounts: true).or(Antenna.joins(:antenna_accounts).where(antenna_accounts: { account: @status.account }).map(&:antenna)))
|
||||
p '=========================== DEBUG B ' + antennas.size.to_s
|
||||
p '=========================== DEBUG C ' + antennas.size.to_s
|
||||
p '=========================== DEBUG D ' + antennas.size.to_s
|
||||
antennas = antennas.left_joins(:antenna_accounts).where(any_accounts: true).or(Antenna.left_joins(:antenna_accounts) .where(antenna_accounts: { exclude: false, account: @status.account }))
|
||||
antennas = antennas.left_joins(:antenna_domains) .where(any_domains: true) .or(Antenna.left_joins(:antenna_accounts).left_joins(:antenna_domains) .where(antenna_domains: { exclude: false, name: @status.account.domain }))
|
||||
antennas = antennas.left_joins(:antenna_tags) .where(any_tags: true) .or(Antenna.left_joins(:antenna_accounts).left_joins(:antenna_domains).left_joins(:antenna_tags).where(antenna_tags: { exclude: false, tag: @status.tags }))
|
||||
antennas.in_batches do |ans|
|
||||
ans.each do |antenna|
|
||||
next if !antenna.enabled?
|
||||
next if antenna.keywords.any? && !@status.text.include?(antenna.keywords)
|
||||
next if antenna.exclude_keywords.any? && @status.text.include?(antenna.exclude_keywords)
|
||||
next if antenna.keywords.any? && !antenna.keywords.any? { |keyword| @status.text.include?(keyword) }
|
||||
next if antenna.exclude_keywords.any? && antenna.exclude_keywords.any? { |keyword| @status.text.include?(keyword) }
|
||||
next if antenna.antenna_accounts.where(exclude: true, account: @status.account).any?
|
||||
next if antenna.antenna_domains.where(exclude: true, name: @status.account.domain).any?
|
||||
next if antenna.antenna_tags.where(exclude: true, tag: @status.tags).any?
|
||||
lists << antenna.list
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
.permissions-list__item__text__title
|
||||
= t('antennas.index.domains', count: antenna.antenna_domains.size)
|
||||
.permissions-list__item__text__type
|
||||
- domains = antenna.antenna_domains
|
||||
- domains = antenna.antenna_domains.map { |domain| domain.name }
|
||||
- domains = domains.take(5) + ['…'] if domains.size > 5 # TODO
|
||||
= domains.join(', ')
|
||||
- unless antenna.antenna_accounts.empty?
|
||||
|
|
|
@ -964,6 +964,27 @@ en:
|
|||
empty: You have no aliases.
|
||||
hint_html: If you want to move from another account to this one, here you can create an alias, which is required before you can proceed with moving followers from the old account to this one. This action by itself is <strong>harmless and reversible</strong>. <strong>The account migration is initiated from the old account</strong>.
|
||||
remove: Unlink alias
|
||||
antennas:
|
||||
contexts:
|
||||
account: Accounts
|
||||
domain: Domains
|
||||
keyword: Keywords
|
||||
tag: Tags
|
||||
edit:
|
||||
title: Edit antenna
|
||||
errors:
|
||||
deprecated_api_multiple_keywords: These parameters cannot be changed from this application because they apply to more than one filter keyword. Use a more recent application or the web interface.
|
||||
invalid_context: None or invalid context supplied
|
||||
index:
|
||||
contexts: Antennas in %{contexts}
|
||||
delete: Delete
|
||||
empty: You have no antennas.
|
||||
expires_in: Expires in %{distance}
|
||||
expires_on: Expires on %{date}
|
||||
title: Antennas
|
||||
new:
|
||||
save: Save new antenna
|
||||
title: Add new antenna
|
||||
appearance:
|
||||
advanced_web_interface: Advanced web interface
|
||||
advanced_web_interface_hint: 'If you want to make use of your entire screen width, the advanced web interface allows you to configure many different columns to see as much information at the same time as you want: Home, notifications, federated timeline, any number of lists and hashtags.'
|
||||
|
|
|
@ -946,6 +946,32 @@ ja:
|
|||
empty: エイリアスがありません。
|
||||
hint_html: 他のアカウントからこのアカウントにフォロワーを引き継いで引っ越したい場合、ここでエイリアスを作成しておく必要があります。エイリアス自体は<strong>無害で、取り消す</strong>ことができます。<strong>引っ越しは以前のアカウント側から開始する必要があります</strong>。
|
||||
remove: エイリアスを削除
|
||||
antennas:
|
||||
contexts:
|
||||
account: アカウント
|
||||
domain: ドメイン
|
||||
keyword: キーワード
|
||||
tag: ハッシュタグ
|
||||
edit:
|
||||
title: アンテナを編集
|
||||
index:
|
||||
accounts:
|
||||
other: "%{count}件のアカウント"
|
||||
contexts: "%{contexts}のアンテナ"
|
||||
delete: 削除
|
||||
domains:
|
||||
other: "%{count}件のドメイン"
|
||||
empty: アンテナはありません。
|
||||
expires_in: "%{distance}で期限切れ"
|
||||
expires_on: 有効期限 %{date}
|
||||
keywords:
|
||||
other: "%{count}件のキーワード"
|
||||
tags:
|
||||
other: "%{count}件のタグ"
|
||||
title: アンテナ
|
||||
new:
|
||||
save: 新規アンテナを保存
|
||||
title: 新規アンテナを追加
|
||||
appearance:
|
||||
advanced_web_interface: 上級者向けUI
|
||||
advanced_web_interface_hint: ディスプレイを幅いっぱいまで活用したい場合、上級者向け UI をおすすめします。ホーム、通知、連合タイムライン、更にはリストやハッシュタグなど、様々な異なるカラムから望む限りの情報を一度に受け取れるような設定が可能になります。
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue