このコミットが含まれているのは:
@@ -732,6 +732,7 @@ class PostsController < ApplicationController
|
||||
|
||||
def post_incoming_snapshot title:, original_created_from:, original_created_before:,
|
||||
tag_names:, video_ms_param:, duration_param:, parent_post_ids:
|
||||
validate_original_created_values!(original_created_from, original_created_before)
|
||||
Tag.normalise_tags!(tag_names, with_tagme: false, deny_deprecated: true,
|
||||
with_sections: true) =>
|
||||
{ tags:, sections: }
|
||||
@@ -769,6 +770,23 @@ class PostsController < ApplicationController
|
||||
value.to_s
|
||||
end
|
||||
|
||||
def validate_original_created_values! original_created_from, original_created_before
|
||||
candidate = Post.new(
|
||||
url: 'https://example.invalid/original-created-validation',
|
||||
original_created_from:,
|
||||
original_created_before:)
|
||||
candidate.valid?
|
||||
fields = [:original_created_from, :original_created_before, :original_created_at]
|
||||
relevant_errors = candidate.errors.select { fields.include?(_1.attribute) }
|
||||
return if relevant_errors.empty?
|
||||
|
||||
invalid_post = Post.new
|
||||
relevant_errors.each { |error|
|
||||
invalid_post.errors.add(error.attribute, error.message)
|
||||
}
|
||||
raise ActiveRecord::RecordInvalid, invalid_post
|
||||
end
|
||||
|
||||
def section_literal section
|
||||
"[#{ Post.ms_to_time(section[0]) }-#{ section[1] ? Post.ms_to_time(section[1]) : '' }]"
|
||||
end
|
||||
|
||||
@@ -201,7 +201,7 @@ class PostCreatePlan
|
||||
|
||||
def serialised_tags direct_tag_specs, tag_sections
|
||||
direct_tag_specs.map { |spec|
|
||||
"#{ spec[:name] }#{ tag_sections[spec[:name]].to_a.map { Post.section_literal(_1) }.join }"
|
||||
"#{ spec[:name] }#{ tag_sections[spec[:name]].to_a.map { section_literal(_1) }.join }"
|
||||
}.sort.join(' ')
|
||||
end
|
||||
|
||||
@@ -210,10 +210,15 @@ class PostCreatePlan
|
||||
{
|
||||
name: spec[:name],
|
||||
category: spec[:category].to_s,
|
||||
section_literals: tag_sections[spec[:name]].to_a.map { Post.section_literal(_1) } }
|
||||
section_literals: tag_sections[spec[:name]].to_a.map { section_literal(_1) } }
|
||||
}.sort_by { _1[:name] }
|
||||
end
|
||||
|
||||
def section_literal range
|
||||
begin_ms, end_ms = range
|
||||
"[#{ Post.ms_to_time(begin_ms) }-#{ end_ms ? Post.ms_to_time(end_ms) : '' }]"
|
||||
end
|
||||
|
||||
def normalise_video_ms snapshot_tag_specs
|
||||
return nil unless snapshot_tag_specs.any? { _1[:name] == VIDEO_TAG_NAME }
|
||||
|
||||
|
||||
新しい課題から参照
ユーザをブロックする