diff --git a/app/lib/inline_renderer.rb b/app/lib/inline_renderer.rb index 7071bb6804..ebdd1d189f 100644 --- a/app/lib/inline_renderer.rb +++ b/app/lib/inline_renderer.rb @@ -12,6 +12,9 @@ class InlineRenderer when :status serializer = REST::StatusSerializer preload_associations_for_status + when :status_internal + serializer = REST::StatusInternalSerializer + preload_associations_for_status when :notification serializer = REST::NotificationSerializer when :emoji_reaction diff --git a/app/models/custom_filter.rb b/app/models/custom_filter.rb index 5a19942e88..f443d08ca6 100644 --- a/app/models/custom_filter.rb +++ b/app/models/custom_filter.rb @@ -101,7 +101,10 @@ class CustomFilter < ApplicationRecord next if filter.exclude_follows && following next if filter.exclude_localusers && status.account.local? - match = rules[:keywords].match(status.proper.searchable_text) if rules[:keywords].present? + if rules[:keywords].present? + match = rules[:keywords].match(status.proper.searchable_text) + match = rules[:keywords].match(status.proper.references.pluck(:text).join("\n\n")) if match.nil? && status.proper.references.exists? + end keyword_matches = [match.to_s] unless match.nil? status_matches = [status.id, status.reblog_of_id].compact & rules[:status_ids] if rules[:status_ids].present? diff --git a/app/serializers/rest/status_internal_serializer.rb b/app/serializers/rest/status_internal_serializer.rb new file mode 100644 index 0000000000..7a2cbf5746 --- /dev/null +++ b/app/serializers/rest/status_internal_serializer.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class REST::StatusInternalSerializer < REST::StatusSerializer + attributes :reference_texts + + def reference_texts + object.references.pluck(:text) + end +end diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index 94f9612725..865589dacd 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -195,7 +195,7 @@ class FanOutOnWriteService < BaseService end def rendered_status - @rendered_status ||= InlineRenderer.render(@status, nil, :status) + @rendered_status ||= InlineRenderer.render(@status, nil, :status_internal) end def update? diff --git a/streaming/index.js b/streaming/index.js index 7bd3ddb0a7..8b16bfe533 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -763,6 +763,11 @@ const startServer = async () => { const listener = message => { const { event, payload } = message; + // reference_texts property is not working if ProcessReferencesWorker is + // used on PostStatusService and so on. (Asynchronous processing) + const reference_texts = payload.reference_texts || []; + delete payload.reference_texts; + // Streaming only needs to apply filtering to some channels and only to // some events. This is because majority of the filtering happens on the // Ruby on Rails side when producing the event for streaming. @@ -908,7 +913,7 @@ const startServer = async () => { if (req.cachedFilters) { const status = payload; // TODO: Calculate searchableContent in Ruby on Rails: - const searchableContent = ([status.spoiler_text || '', status.content].concat((status.poll && status.poll.options) ? status.poll.options.map(option => option.title) : [])).concat(status.media_attachments.map(att => att.description)).join('\n\n').replace(//g, '\n').replace(/<\/p>

/g, '\n\n'); + const searchableContent = ([status.spoiler_text || '', status.content, ...(reference_texts || [])].concat((status.poll && status.poll.options) ? status.poll.options.map(option => option.title) : [])).concat(status.media_attachments.map(att => att.description)).join('\n\n').replace(//g, '\n').replace(/<\/p>

/g, '\n\n'); const searchableTextContent = JSDOM.fragment(searchableContent).textContent; const now = new Date();