# typed: strict
class Domain::PostFileThumbnailJob < Scraper::JobBase
  queue_as :thumbnails
  discard_on Vips::Error

  sig { override.returns(Symbol) }
  def self.http_factory_method
    raise NotImplementedError
  end

  sig { override.params(args: T::Hash[Symbol, T.untyped]).returns(T.untyped) }
  def perform(args)
    post_file = T.cast(args[:post_file], Domain::PostFile)
    unless post_file.state_ok?
      logger.warn("post file not in ok state, skipping")
      return
    end
    Domain::PostFile::Thumbnail.create_for_post_file!(post_file)
    Domain::PostFile::BitFingerprint.create_for_post_file!(post_file)
    nil
  end
end
