From c811a79c9b1a39d2a4c8f22f169f2466a94d4ee1 Mon Sep 17 00:00:00 2001 From: JS Moore Date: Sat, 9 Mar 2024 18:08:05 -0500 Subject: [PATCH] Add status to the list feed when the tag matches. --- app/controllers/api/v1/lists/accounts_controller.rb | 1 - app/controllers/api/v1/lists/tags_controller.rb | 1 - app/lib/feed_manager.rb | 2 -- app/models/tag.rb | 3 +++ app/services/fan_out_on_write_service.rb | 5 +++++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/lists/accounts_controller.rb b/app/controllers/api/v1/lists/accounts_controller.rb index 0f1c2cd0b9..0604ad60fc 100644 --- a/app/controllers/api/v1/lists/accounts_controller.rb +++ b/app/controllers/api/v1/lists/accounts_controller.rb @@ -32,7 +32,6 @@ class Api::V1::Lists::AccountsController < Api::BaseController private def set_list - Rails.logger.warn "This is concerning! #{current_account} and #{params}" @list = List.where(account: current_account).find(params[:list_id]) end diff --git a/app/controllers/api/v1/lists/tags_controller.rb b/app/controllers/api/v1/lists/tags_controller.rb index c255821856..c108d3d4df 100644 --- a/app/controllers/api/v1/lists/tags_controller.rb +++ b/app/controllers/api/v1/lists/tags_controller.rb @@ -32,7 +32,6 @@ class Api::V1::Lists::TagsController < Api::BaseController private def set_list - Rails.logger.warn "This is tagged concerning! #{current_account} and #{params}" @list = List.where(account: current_account).find(params[:list_id]) end diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index cdf4cdd228..c71fc5c649 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -443,13 +443,11 @@ class FeedManager should_filter = !crutches[:following][status.in_reply_to_account_id] # and I'm not following the person it's a reply to should_filter &&= receiver_id != status.in_reply_to_account_id # and it's not a reply to me should_filter &&= status.account_id != status.in_reply_to_account_id # and it's not a self-reply - return !!should_filter elsif status.reblog? # Filter out a reblog should_filter = crutches[:hiding_reblogs][status.account_id] # if the reblogger's reblogs are suppressed should_filter ||= crutches[:blocked_by][status.reblog.account_id] # or if the author of the reblogged status is blocking me should_filter ||= crutches[:domain_blocking][status.reblog.account.domain] # or the author's domain is blocked - return !!should_filter end diff --git a/app/models/tag.rb b/app/models/tag.rb index f2168ae904..98e4e6297a 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -28,6 +28,9 @@ class Tag < ApplicationRecord has_many :featured_tags, dependent: :destroy, inverse_of: :tag has_many :followers, through: :passive_relationships, source: :account + has_many :list_tags, inverse_of: :tag, dependent: :destroy + has_many :lists, through: :list_tags + HASHTAG_SEPARATORS = "_\u00B7\u30FB\u200c" HASHTAG_FIRST_SEQUENCE_CHUNK_ONE = "[[:word:]_][[:word:]#{HASHTAG_SEPARATORS}]*[[:alpha:]#{HASHTAG_SEPARATORS}]" HASHTAG_FIRST_SEQUENCE_CHUNK_TWO = "[[:word:]#{HASHTAG_SEPARATORS}]*[[:word:]_]" diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index 71ab1ac494..71f3903675 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -113,6 +113,11 @@ class FanOutOnWriteService < BaseService end def deliver_to_lists! + @status.tags.each do |tag| + FeedInsertWorker.push_bulk(tag.lists) do |list| + [@status.id, list.id, 'list', { 'update' => update? }] + end + end @account.lists_for_local_distribution.select(:id).reorder(nil).find_in_batches do |lists| FeedInsertWorker.push_bulk(lists) do |list| [@status.id, list.id, 'list', { 'update' => update? }]