Skip to content

Commit

Permalink
move method body and remove fetch_content_type method
Browse files Browse the repository at this point in the history
I was thinking this method shouldn't be in Media, talking to Caio he suggested
this shouldn't be it's own method, since it's only used here.
  • Loading branch information
vasconsaurus committed Jan 29, 2025
1 parent 1f50b39 commit 8cb5dff
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions app/models/media.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def domain
def self.find_or_create_from_original_claim(claim, project_media_team)
if claim.match?(/\A#{URI::DEFAULT_PARSER.make_regexp(['http', 'https'])}\z/)
uri = URI.parse(claim)
content_type = fetch_content_type(uri)
content_type = Net::HTTP.get_response(uri)['content-type']
ext = File.extname(uri.path)

case content_type
Expand Down Expand Up @@ -130,11 +130,6 @@ def set_original_claim_hash
self.original_claim_hash = Digest::MD5.hexdigest(original_claim) unless self.original_claim.blank?
end

def self.fetch_content_type(uri)
response = Net::HTTP.get_response(uri)
response['content-type']
end

def self.create_uploaded_file_media_from_original_claim(media_type, url, ext)
klass = media_type.constantize
file = download_file(url, ext)
Expand Down

0 comments on commit 8cb5dff

Please sign in to comment.