mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
Whole word import/export
This commit is contained in:
parent
3e6fac42c1
commit
9c9dd66129
|
@ -56,9 +56,9 @@ class Export
|
|||
end
|
||||
|
||||
def to_filters_csv
|
||||
CSV.generate(headers: ['Title', 'Context', 'Keywords', 'Action', 'Expire after'], write_headers: true) do |csv|
|
||||
CSV.generate(headers: ['Title', 'Context', 'Keywords', 'Whole Word', 'Action', 'Expire after'], write_headers: true) do |csv|
|
||||
account.custom_filters.reorder(id: :desc).each do |filter|
|
||||
csv << [filter.title, filter.context, filter.keywords.map(&:keyword), filter.action, filter.expires_at]
|
||||
csv << [filter.title, filter.context, filter.keywords.map(&:keyword), filter.keywords.map(&:whole_word), filter.action, filter.expires_at]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ class Form::Import
|
|||
domain_blocking: ['#domain'],
|
||||
bookmarks: ['#uri'],
|
||||
lists: ['List name', 'Account address'],
|
||||
filters: ['Title', 'Context', 'Keywords', 'Action', 'Expire after'],
|
||||
filters: ['Title', 'Context', 'Keywords', 'Whole Word', 'Action', 'Expire after'],
|
||||
}.freeze
|
||||
|
||||
KNOWN_FIRST_HEADERS = EXPECTED_HEADERS_BY_TYPE.values.map(&:first).uniq.freeze
|
||||
|
@ -38,6 +38,7 @@ class Form::Import
|
|||
'Title' => 'title',
|
||||
'Context' => 'context',
|
||||
'Keywords' => 'keywords',
|
||||
'Whole Word' => 'whole_word',
|
||||
'Action' => 'action',
|
||||
'Expire after' => 'expires_at',
|
||||
}.freeze
|
||||
|
@ -124,7 +125,7 @@ class Form::Import
|
|||
case type.to_sym
|
||||
when :filters
|
||||
case field_info.header
|
||||
when 'Context', 'Keywords'
|
||||
when 'Context', 'Keywords', 'Whole Word'
|
||||
Oj.load(field)
|
||||
when 'Expire after'
|
||||
field.blank? ? nil : Time.zone.parse(field)
|
||||
|
|
|
@ -42,7 +42,7 @@ class BulkImportRowService
|
|||
when :filters
|
||||
filter = @account.custom_filters.find_or_initialize_by(title: @data['title'])
|
||||
filter.context = @data['context']
|
||||
filter.keywords = @data['keywords'].map { |keyword| CustomFilterKeyword.new(keyword: keyword) }
|
||||
filter.keywords = @data['keywords'].map.with_index { |keyword, i| CustomFilterKeyword.new(keyword: keyword, whole_word: @data['whole_word'][i]) }
|
||||
filter.action = @data['action'].to_sym
|
||||
filter.expires_at = @data['expires_at']
|
||||
filter.save!
|
||||
|
|
Loading…
Reference in New Issue
Block a user