diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-03-18 22:51:20 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-03-18 22:51:20 +0100 |
commit | 2816b1bf8efa61af5abc045a2567220e71f6dad1 (patch) | |
tree | cd75548d1f4da9debf5642b73a8a45034f6e0559 /app/models | |
parent | 5cfc9c74872fff63f3ddf81de0baebfd50e2fc72 (diff) |
Federate header images, fix open-uri http->https redirection error
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 978dc2d71..aa0af563c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -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 |