# typed: strict
class Domain::PostGroup::SofurryFolder < Domain::PostGroup
  include AttrJsonRecordAliases
  include HasAttrJsonEnum
  include HasTimestampsWithDueAt

  class_attribute :due_at_timestamp_fields

  attr_json :sofurry_id, :integer
  attr_json :name, :string
  attr_json :owner_id, :integer
  attr_json :media_types, :string, array: true
  attr_json_due_timestamp :scanned_folder_at, 3.months

  belongs_to :owner, class_name: "::Domain::User::SofurryUser", optional: true

  sig { override.returns([String, Symbol]) }
  def self.param_prefix_and_attribute
    ["sf", :sofurry_folder_id]
  end

  sig { override.returns(T.nilable(String)) }
  def external_url_for_view
    if (type = self.media_types.first) && (sofurry_id = self.sofurry_id) &&
         (owner_id = self.owner&.sofurry_id)
      "https://www.sofurry.com/browse/folder/#{type}?by=#{owner_id}&folder=#{sofurry_id}"
    end
  end
end
