From 2816b1bf8efa61af5abc045a2567220e71f6dad1 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 18 Mar 2017 22:51:20 +0100 Subject: Federate header images, fix open-uri http->https redirection error --- app/models/account.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app/models') 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 -- cgit