Federate header images, fix open-uri http->https redirection error
This commit is contained in:
parent
5cfc9c7487
commit
2816b1bf8e
6 changed files with 34 additions and 1 deletions
|
@ -144,7 +144,9 @@ class Account < ApplicationRecord
|
|||
save!
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
self.avatar = nil
|
||||
self.header = nil
|
||||
self[:avatar_remote_url] = ''
|
||||
self[:header_remote_url] = ''
|
||||
save!
|
||||
end
|
||||
|
||||
|
@ -159,6 +161,17 @@ class Account < ApplicationRecord
|
|||
Rails.logger.debug "Error fetching remote avatar: #{e}"
|
||||
end
|
||||
|
||||
def header_remote_url=(url)
|
||||
parsed_url = URI.parse(url)
|
||||
|
||||
return if !%w(http https).include?(parsed_url.scheme) || parsed_url.host.empty? || self[:header_remote_url] == url
|
||||
|
||||
self.header = parsed_url
|
||||
self[:header_remote_url] = url
|
||||
rescue OpenURI::HTTPError => e
|
||||
Rails.logger.debug "Error fetching remote header: #{e}"
|
||||
end
|
||||
|
||||
def object_type
|
||||
:person
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue