このコミットが含まれているのは:
@@ -1,9 +1,12 @@
|
||||
class PostCreator
|
||||
class VideoMsParseError < ArgumentError; end
|
||||
|
||||
attr_reader :field_warnings
|
||||
|
||||
def initialize actor:, attributes:
|
||||
@actor = actor
|
||||
@attributes = attributes.symbolize_keys
|
||||
@field_warnings = { }
|
||||
end
|
||||
|
||||
def create!
|
||||
@@ -13,8 +16,7 @@ class PostCreator
|
||||
uploaded_user: @actor,
|
||||
original_created_from: @attributes[:original_created_from].presence,
|
||||
original_created_before: @attributes[:original_created_before].presence)
|
||||
thumbnail = @attributes[:thumbnail]
|
||||
post.thumbnail.attach(Post.resized_thumbnail_attachment(thumbnail)) if thumbnail.present?
|
||||
attach_thumbnail!(post)
|
||||
|
||||
ApplicationRecord.transaction do
|
||||
post.save!
|
||||
@@ -34,6 +36,21 @@ class PostCreator
|
||||
|
||||
private
|
||||
|
||||
def attach_thumbnail! post
|
||||
thumbnail = @attributes[:thumbnail]
|
||||
if thumbnail.present?
|
||||
post.thumbnail.attach(Post.resized_thumbnail_attachment(thumbnail))
|
||||
return
|
||||
end
|
||||
|
||||
thumbnail_base = post.thumbnail_base
|
||||
return if thumbnail_base.blank?
|
||||
|
||||
post.attach_thumbnail_from_url!(thumbnail_base)
|
||||
rescue Post::RemoteThumbnailFetchFailed => e
|
||||
@field_warnings[:thumbnail_base] = [e.message]
|
||||
end
|
||||
|
||||
def tag_names = @attributes[:tags].to_s.split
|
||||
|
||||
def parent_post_ids
|
||||
|
||||
新しい課題から参照
ユーザをブロックする