1
0
Fork 0
forked from gitea/nas

Make antenna able to insert home

This commit is contained in:
KMY 2023-05-09 15:07:29 +09:00
parent 7c118ed1d0
commit 9429f5b60c
7 changed files with 34 additions and 8 deletions

View file

@ -145,7 +145,7 @@ class StatusReachFinder
def banned_domains_for_misskey
return @banned_domains_for_misskey if @banned_domains_for_misskey
return @banned_domains_for_misskey = [] if (!@status.account.user&.reject_public_unlisted_subscription? && !@status.account.user&.reject_unlisted_subscription?) || (!@status.public_unlisted_visibility? && !@status.unlisted_visibility?)
return @banned_domains_for_misskey = [] if (!@status.account.user&.setting_reject_public_unlisted_subscription? && !@status.account.user&.reject_unlisted_subscription?) || (!@status.public_unlisted_visibility? && !@status.unlisted_visibility?)
domains = banned_domains_for_misskey_of_status(@status)
domains += banned_domains_for_misskey_of_status(@status.reblog) if @status.reblog? && @status.reblog.local?

View file

@ -31,7 +31,7 @@ class Antenna < ApplicationRecord
has_many :antenna_accounts, inverse_of: :antenna, dependent: :destroy
belongs_to :account
belongs_to :list
belongs_to :list, optional: true
scope :all_keywords, -> { where(any_keywords: true) }
scope :all_domains, -> { where(any_domains: true) }
@ -42,7 +42,7 @@ class Antenna < ApplicationRecord
validate :list_owner
def list_owner
raise Mastodon::ValidationError, I18n.t('antennas.errors.invalid_list_owner') if list.account != account
raise Mastodon::ValidationError, I18n.t('antennas.errors.invalid_list_owner') if list.present? && list.account != account
end
def enabled?

View file

@ -118,6 +118,7 @@ class FanOutOnWriteService < BaseService
def deliver_to_antennas!
lists = []
homes = []
tag_ids = @status.tags.pluck(:id)
domain = @account.domain || Rails.configuration.x.local_domain
@ -142,16 +143,27 @@ class FanOutOnWriteService < BaseService
next if antenna.exclude_domains&.include?(domain)
next if antenna.exclude_tags&.any? { |tag_id| tag_ids.include?(tag_id) }
lists << antenna.list_id
if antenna.list_id.zero?
homes << antenna.account_id
else
lists << antenna.list_id
end
end
end
lists = lists.uniq
homes = homes.uniq
if lists.any?
FeedInsertWorker.push_bulk(lists) do |list|
[@status.id, list, 'list', { 'update' => update? }]
end
end
if homes.any?
FeedInsertWorker.push_bulk(homes) do |home|
[@status.id, home, 'home', { 'update' => update? }]
end
end
end
def deliver_to_mentioned_followers!

View file

@ -13,7 +13,7 @@
= t('antennas.index.expires_in', distance: distance_of_time_in_words_to_now(antenna.expires_at))
.listname
= antenna.list.title
= antenna.list&.title || '[Insert to Home]'
.filters-list__item__permissions
%ul.permissions-list

View file

@ -9,7 +9,7 @@
.fields-row
.fields-group.fields-row__column.fields-row__column-6
= f.input :list, collection: lists, wrapper: :with_label, label_method: lambda { |list| list.title }, label: t('antennas.edit.list'), selected: f.object.list&.id, hint: false
= f.input :list, collection: lists, wrapper: :with_label, label_method: lambda { |list| list.title }, label: t('antennas.edit.list'), selected: f.object.list&.id, hint: false, include_blank: '[Insert to Home]'
.fields-group.fields-row__column.fields-row__column-6
= f.input :available, wrapper: :with_label, label: t('antennas.edit.available'), hint: false