このコミットが含まれているのは:
@@ -1,6 +1,5 @@
|
||||
class PostsController < ApplicationController
|
||||
Event = Struct.new(:post, :tag, :user, :change_type, :timestamp, keyword_init: true)
|
||||
MAX_BULK_THUMBNAIL_BYTES = 20 * 1024 * 1024
|
||||
MAX_BULK_REQUEST_BYTES = 40 * 1024 * 1024
|
||||
|
||||
class VideoMsParseError < ArgumentError
|
||||
@@ -178,7 +177,7 @@ class PostsController < ApplicationController
|
||||
preflight = PostCreatePreflight.new(
|
||||
attributes: post_create_attributes,
|
||||
thumbnail: params[:thumbnail]).run
|
||||
return render json: preflight if bool?(:dry)
|
||||
return render json: dry_run_json(preflight) if bool?(:dry)
|
||||
|
||||
post = PostCreator.new(actor: current_user,
|
||||
attributes: post_create_attributes.merge(
|
||||
@@ -191,7 +190,10 @@ class PostsController < ApplicationController
|
||||
:original_created_from,
|
||||
:original_created_before,
|
||||
:duration,
|
||||
:video_ms).symbolize_keys).merge(
|
||||
:video_ms,
|
||||
:normalised_tags,
|
||||
:tag_sections,
|
||||
:normalised_parent_post_ids).symbolize_keys).merge(
|
||||
thumbnail: params[:thumbnail])).create!
|
||||
|
||||
post.reload
|
||||
@@ -566,7 +568,6 @@ class PostsController < ApplicationController
|
||||
unless value.is_a?(ActionDispatch::Http::UploadedFile)
|
||||
raise ArgumentError, 'thumbnail upload が不正です.'
|
||||
end
|
||||
raise ArgumentError, 'thumbnail file size が大きすぎます.' if value.size > MAX_BULK_THUMBNAIL_BYTES
|
||||
|
||||
thumbnails[index] = value
|
||||
end
|
||||
@@ -581,6 +582,22 @@ class PostsController < ApplicationController
|
||||
PostCompactRepr.base(post)
|
||||
end
|
||||
|
||||
def dry_run_json preflight
|
||||
preflight.slice(
|
||||
:url,
|
||||
:title,
|
||||
:thumbnail_base,
|
||||
:tags,
|
||||
:parent_post_ids,
|
||||
:original_created_from,
|
||||
:original_created_before,
|
||||
:duration,
|
||||
:video_ms,
|
||||
:field_warnings,
|
||||
:base_warnings,
|
||||
:existing_post)
|
||||
end
|
||||
|
||||
def sync_parent_posts! post, parent_post_ids
|
||||
if parent_post_ids.include?(post.id)
|
||||
post.errors.add :parent_post_ids, '自分自身を親投稿にはできません.'
|
||||
|
||||
新しい課題から参照
ユーザをブロックする