mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
Import seems to work!
This commit is contained in:
parent
dbdf20b373
commit
d8725ea554
|
@ -57,6 +57,8 @@ class Settings::ImportsController < Settings::BaseController
|
|||
csv << [row.data['uri']]
|
||||
when :lists
|
||||
csv << [row.data['list_name'], row.data['acct']]
|
||||
when :filters
|
||||
csv << [row.data['title'], row.data['context'], row.data['keywords'], row.data['action'], row.data['expires_at']]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,6 +33,13 @@ class Form::Import
|
|||
'#domain' => 'domain',
|
||||
'#uri' => 'uri',
|
||||
'List name' => 'list_name',
|
||||
|
||||
# Filters
|
||||
'Title' => 'title',
|
||||
'Context' => 'context',
|
||||
'Keywords' => 'keywords',
|
||||
'Action' => 'action',
|
||||
'Expire after' => 'expires_at',
|
||||
}.freeze
|
||||
|
||||
class EmptyFileError < StandardError; end
|
||||
|
@ -114,10 +121,11 @@ class Form::Import
|
|||
return @csv_data if defined?(@csv_data)
|
||||
|
||||
csv_converter = lambda do |field, field_info|
|
||||
if :type == :filters
|
||||
case type.to_sym
|
||||
when :filters
|
||||
case field_info.header
|
||||
when 'Context', 'Keywords'
|
||||
field&.split(',')&.map(&:strip)&.presence
|
||||
Oj.load(field)
|
||||
when 'Expire after'
|
||||
field.blank? ? nil : Time.zone.parse(field)
|
||||
else
|
||||
|
|
|
@ -39,6 +39,13 @@ class BulkImportRowService
|
|||
FollowService.new.call(@account, @target_account) unless @account.id == @target_account.id
|
||||
|
||||
list.accounts << @target_account
|
||||
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.action = @data['action'].to_sym
|
||||
filter.expires_at = @data['expires_at']
|
||||
filter.save!
|
||||
end
|
||||
|
||||
true
|
||||
|
|
Loading…
Reference in New Issue
Block a user