Reviewed-on: #413 Co-authored-by: miteruzo <miteruzo@naver.com> Co-committed-by: miteruzo <miteruzo@naver.com>
このコミットはPull リクエスト #413 でマージされました.
このコミットが含まれているのは:
@@ -70,11 +70,17 @@ namespace :nico do
|
||||
unless post.thumbnail.attached?
|
||||
thumbnail_base = fetch_thumbnail.(post.url) rescue nil
|
||||
if thumbnail_base.present?
|
||||
post.thumbnail.attach(
|
||||
io: URI.open(thumbnail_base),
|
||||
filename: File.basename(URI.parse(thumbnail_base).path),
|
||||
content_type: 'image/jpeg')
|
||||
attrs[:thumbnail_base] = thumbnail_base
|
||||
begin
|
||||
post.attach_thumbnail_from_url!(thumbnail_base)
|
||||
rescue Post::RemoteThumbnailFetchFailed => e
|
||||
payload = {
|
||||
post_id: post.id,
|
||||
thumbnail_base:,
|
||||
error: e.class.name,
|
||||
message: e.message }
|
||||
Rails.logger.info("nico_sync_thumbnail_fetch_failed #{ payload.to_json }")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -82,7 +88,6 @@ namespace :nico do
|
||||
post_changed = post.changed?
|
||||
if post_changed
|
||||
post.save!
|
||||
post.resized_thumbnail! if post.thumbnail.attached?
|
||||
end
|
||||
else
|
||||
post_created = true
|
||||
@@ -91,13 +96,18 @@ namespace :nico do
|
||||
post = Post.new(title:, url:, thumbnail_base:, uploaded_user: nil,
|
||||
original_created_from:, original_created_before:)
|
||||
if thumbnail_base.present?
|
||||
post.thumbnail.attach(
|
||||
io: URI.open(thumbnail_base),
|
||||
filename: File.basename(URI.parse(thumbnail_base).path),
|
||||
content_type: 'image/jpeg')
|
||||
begin
|
||||
post.attach_thumbnail_from_url!(thumbnail_base)
|
||||
rescue Post::RemoteThumbnailFetchFailed => e
|
||||
payload = {
|
||||
post_id: nil,
|
||||
thumbnail_base:,
|
||||
error: e.class.name,
|
||||
message: e.message }
|
||||
Rails.logger.info("nico_sync_thumbnail_fetch_failed #{ payload.to_json }")
|
||||
end
|
||||
end
|
||||
post.save!
|
||||
post.resized_thumbnail!
|
||||
sync_post_tags!(post, [Tag.tagme.id, Tag.bot.id, Tag.niconico.id, Tag.video.id])
|
||||
end
|
||||
|
||||
|
||||
新しい課題から参照
ユーザをブロックする