闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: imports
  5. #
  6. # id :bigint(8) not null, primary key
  7. # type :integer not null
  8. # approved :boolean default(FALSE), not null
  9. # created_at :datetime not null
  10. # updated_at :datetime not null
  11. # data_file_name :string
  12. # data_content_type :string
  13. # data_file_size :integer
  14. # data_updated_at :datetime
  15. # account_id :bigint(8) not null
  16. # overwrite :boolean default(FALSE), not null
  17. #
  18. class Import < ApplicationRecord
  19. FILE_TYPES = %w(text/plain text/csv).freeze
  20. MODES = %i(merge overwrite).freeze
  21. self.inheritance_column = false
  22. belongs_to :account
  23. enum type: [:following, :blocking, :muting, :domain_blocking]
  24. validates :type, presence: true
  25. has_attached_file :data
  26. validates_attachment_content_type :data, content_type: FILE_TYPES
  27. validates_attachment_presence :data
  28. def mode
  29. overwrite? ? :overwrite : :merge
  30. end
  31. def mode=(str)
  32. self.overwrite = str.to_sym == :overwrite
  33. end
  34. end