このコミットが含まれているのは:
@@ -158,10 +158,8 @@ class Post < ApplicationRecord
|
||||
def attach_thumbnail_from_url! raw_url
|
||||
response = Preview::ThumbnailFetcher.fetch_image_response(raw_url)
|
||||
thumbnail.attach(
|
||||
io: StringIO.new(response.body),
|
||||
filename: remote_thumbnail_filename(response.url),
|
||||
content_type: response.content_type)
|
||||
resized_thumbnail!
|
||||
self.class.resized_thumbnail_attachment(
|
||||
StringIO.new(response.body)))
|
||||
rescue Preview::UrlSafety::UnsafeUrl,
|
||||
Preview::ThumbnailFetcher::GenerationFailed,
|
||||
Preview::HttpFetcher::FetchFailed,
|
||||
@@ -173,15 +171,6 @@ class Post < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def remote_thumbnail_filename url
|
||||
filename = File.basename(URI.parse(url).path.to_s)
|
||||
return filename if filename.present? && filename != '/'
|
||||
|
||||
'thumbnail'
|
||||
rescue URI::InvalidURIError
|
||||
'thumbnail'
|
||||
end
|
||||
|
||||
def validate_original_created_range
|
||||
f = parse_original_created_value(:original_created_from)
|
||||
b = parse_original_created_value(:original_created_before)
|
||||
|
||||
@@ -81,12 +81,22 @@ class PostMetadataFetcher
|
||||
day = match[3].to_i
|
||||
hour = match[4].to_i
|
||||
minute = match[5]&.to_i || 0
|
||||
second = match[6]&.to_i || 0
|
||||
fraction = match[7]
|
||||
offset = match[8]
|
||||
nanoseconds = parse_nanoseconds(fraction)
|
||||
timestamp =
|
||||
if offset.present?
|
||||
Time.new(year, month, day, hour, minute, 0, parse_offset(offset)).in_time_zone
|
||||
Time.new(
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
hour,
|
||||
minute,
|
||||
second + Rational(nanoseconds, 1_000_000_000),
|
||||
parse_offset(offset)).in_time_zone
|
||||
else
|
||||
Time.zone.local(year, month, day, hour, minute)
|
||||
Time.zone.local(year, month, day, hour, minute, second).change(nsec: nanoseconds)
|
||||
end
|
||||
|
||||
from = timestamp.change(sec: 0, nsec: 0)
|
||||
@@ -94,6 +104,13 @@ class PostMetadataFetcher
|
||||
[from, before]
|
||||
end
|
||||
|
||||
def self.parse_nanoseconds value
|
||||
return 0 if value.blank?
|
||||
|
||||
digits = value[0, 9].ljust(9, '0')
|
||||
Integer(digits, 10)
|
||||
end
|
||||
|
||||
def self.parse_offset value
|
||||
return '+00:00' if value == 'Z'
|
||||
|
||||
@@ -109,6 +126,7 @@ class PostMetadataFetcher
|
||||
private_class_method :platform_tags,
|
||||
:original_created_range,
|
||||
:parse_timestamp_range,
|
||||
:parse_nanoseconds,
|
||||
:parse_offset,
|
||||
:serialise_time
|
||||
end
|
||||
|
||||
新しい課題から参照
ユーザをブロックする