2023-08-25 00:40:04 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-12-01 22:00:41 +11:00
|
|
|
module Status::SearchConcern
|
2023-08-25 00:40:04 +10:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2024-03-14 20:31:57 +11:00
|
|
|
scope :indexable, -> { without_reblogs.public_visibility.joins(:account).where(account: { indexable: true }) }
|
2023-08-25 00:40:04 +10:00
|
|
|
end
|
|
|
|
|
2023-08-30 01:51:13 +10:00
|
|
|
def searchable_by
|
|
|
|
@searchable_by ||= begin
|
|
|
|
ids = []
|
|
|
|
|
|
|
|
ids << account_id if local?
|
2023-08-25 00:40:04 +10:00
|
|
|
|
2023-08-30 01:51:13 +10:00
|
|
|
ids += local_mentioned.pluck(:id)
|
|
|
|
ids += local_favorited.pluck(:id)
|
|
|
|
ids += local_reblogged.pluck(:id)
|
|
|
|
ids += local_bookmarked.pluck(:id)
|
|
|
|
ids += preloadable_poll.local_voters.pluck(:id) if preloadable_poll.present?
|
|
|
|
|
|
|
|
ids.uniq
|
|
|
|
end
|
2023-08-25 00:40:04 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
def searchable_text
|
|
|
|
[
|
|
|
|
spoiler_text,
|
|
|
|
FormattingHelper.extract_status_plain_text(self),
|
|
|
|
preloadable_poll&.options&.join("\n\n"),
|
|
|
|
ordered_media_attachments.map(&:description).join("\n\n"),
|
|
|
|
].compact.join("\n\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
def searchable_properties
|
|
|
|
[].tap do |properties|
|
|
|
|
properties << 'image' if ordered_media_attachments.any?(&:image?)
|
|
|
|
properties << 'video' if ordered_media_attachments.any?(&:video?)
|
|
|
|
properties << 'audio' if ordered_media_attachments.any?(&:audio?)
|
|
|
|
properties << 'media' if with_media?
|
|
|
|
properties << 'poll' if with_poll?
|
|
|
|
properties << 'link' if with_preview_card?
|
2023-11-13 20:58:28 +11:00
|
|
|
properties << 'embed' if preview_card&.video?
|
2023-08-25 00:40:04 +10:00
|
|
|
properties << 'sensitive' if sensitive?
|
|
|
|
properties << 'reply' if reply?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|