This commit is contained in:
Albert Yi
2018-07-25 11:04:50 -07:00
parent 9082ddf455
commit 77854349e5
6 changed files with 37 additions and 22 deletions

View File

@@ -5,7 +5,7 @@ class UploadService
if Utils.is_downloadable?(url) && file.nil?
download = Downloads::File.new(url)
normalized_url, _, _ = download.before_download(url, {})
normalized_url = download.rewrite_url()
post = if normalized_url.nil?
Post.where("SourcePattern(lower(posts.source)) = ?", url).first
else

View File

@@ -222,7 +222,8 @@ class UploadService
def download_for_upload(source, upload)
file = download_from_source(source, referer_url: upload.referer_url) do |context|
upload.downloaded_source = context[:downloaded_source]
upload.source = context[:source]
puts "source: #{source} -> #{context[:source]}"
#upload.source = context[:source]
if context[:ugoira]
upload.context = { ugoira: context[:ugoira] }

View File

@@ -115,7 +115,7 @@ class ArtistUrl < ApplicationRecord
def validate_url_format
uri = Addressable::URI.parse(url)
errors[:url] << " #{uri} must begin with http:// or https://" if !uri.scheme.in?(%w[http https])
errors[:url] << "#{uri} must begin with http:// or https://" if !uri.scheme.in?(%w[http https])
rescue Addressable::URI::InvalidURIError => error
errors[:url] << "is malformed: #{error}"
end