about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/helpers/atom_builder_helper.rb5
-rw-r--r--app/models/account.rb13
-rw-r--r--app/services/update_remote_profile_service.rb1
3 files changed, 19 insertions, 0 deletions
diff --git a/app/helpers/atom_builder_helper.rb b/app/helpers/atom_builder_helper.rb
index 8ca3cde26..b750eeb07 100644
--- a/app/helpers/atom_builder_helper.rb
+++ b/app/helpers/atom_builder_helper.rb
@@ -124,6 +124,10 @@ module AtomBuilderHelper
     single_link_avatar(xml, account, :original, 120)
   end
 
+  def link_header(xml, account)
+    xml.link('rel' => 'header', 'type' => account.header_content_type, 'media:width' => 700, 'media:height' => 335, 'href' => full_asset_url(account.header.url(:original)))
+  end
+
   def logo(xml, url)
     xml.logo url
   end
@@ -160,6 +164,7 @@ module AtomBuilderHelper
     summary          xml, account.note
     link_alternate   xml, TagManager.instance.url_for(account)
     link_avatar      xml, account
+    link_header      xml, account
     portable_contact xml, account
     privacy_scope    xml, account.locked? ? :private : :public
   end
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
diff --git a/app/services/update_remote_profile_service.rb b/app/services/update_remote_profile_service.rb
index dc315db19..74baa1cc5 100644
--- a/app/services/update_remote_profile_service.rb
+++ b/app/services/update_remote_profile_service.rb
@@ -14,6 +14,7 @@ class UpdateRemoteProfileService < BaseService
 
       unless account.suspended? || DomainBlock.find_by(domain: account.domain)&.reject_media?
         account.avatar_remote_url = author_xml.at_xpath('./xmlns:link[@rel="avatar"]', xmlns: TagManager::XMLNS)['href'] unless author_xml.at_xpath('./xmlns:link[@rel="avatar"]', xmlns: TagManager::XMLNS).nil? || author_xml.at_xpath('./xmlns:link[@rel="avatar"]', xmlns: TagManager::XMLNS)['href'].blank?
+        account.header_remote_url = author_xml.at_xpath('./xmlns:link[@rel="header"]', xmlns: TagManager::XMLNS)['href'] unless author_xml.at_xpath('./xmlns:link[@rel="header"]', xmlns: TagManager::XMLNS).nil? || author_xml.at_xpath('./xmlns:link[@rel="header"]', xmlns: TagManager::XMLNS)['href'].blank?
       end
     end