2023-08-24 10:40:04 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-12-01 06:00:41 -05:00
|
|
|
module Status::SearchConcern
|
2023-08-24 10:40:04 -04:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2024-03-14 05:31:57 -04:00
|
|
|
scope :indexable, -> { without_reblogs.public_visibility.joins(:account).where(account: { indexable: true }) }
|
2023-08-24 10:40:04 -04:00
|
|
|
end
|
|
|
|
|
2023-08-29 11:51:13 -04:00
|
|
|
def searchable_by
|
|
|
|
@searchable_by ||= begin
|
|
|
|
ids = []
|
|
|
|
|
|
|
|
ids << account_id if local?
|
2023-08-24 10:40:04 -04:00
|
|
|
|
2023-08-29 11:51:13 -04: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-24 10:40:04 -04: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 04:58:28 -05:00
|
|
|
properties << 'embed' if preview_card&.video?
|
2023-08-24 10:40:04 -04:00
|
|
|
properties << 'sensitive' if sensitive?
|
|
|
|
properties << 'reply' if reply?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|