mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Make site setting type uploaded_image_list use upload IDs (#10401)
It used to be a list of concatenated upload URLs which was prone to break.
This commit is contained in:
@@ -44,5 +44,29 @@ module HasUrl
|
||||
|
||||
result || self.find_by("url LIKE ?", "%#{data[1]}")
|
||||
end
|
||||
|
||||
def get_from_urls(upload_urls)
|
||||
urls = []
|
||||
sha1s = []
|
||||
|
||||
upload_urls.each do |url|
|
||||
next if url.blank?
|
||||
|
||||
uri = begin
|
||||
URI(UrlHelper.unencode(url))
|
||||
rescue URI::Error
|
||||
end
|
||||
|
||||
next if uri&.path.blank?
|
||||
urls << uri.path
|
||||
|
||||
if data = extract_url(uri.path).presence
|
||||
urls << data[1]
|
||||
sha1s << data[2] if self.name == "Upload"
|
||||
end
|
||||
end
|
||||
|
||||
self.where(url: urls).or(self.where(sha1: sha1s))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user