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.rb86
-rw-r--r--app/services/favourite_service.rb8
-rw-r--r--app/services/fetch_atom_service.rb2
-rw-r--r--app/services/unfavourite_service.rb8
-rw-r--r--app/workers/after_remote_follow_request_worker.rb2
-rw-r--r--app/workers/after_remote_follow_worker.rb2
6 files changed, 55 insertions, 53 deletions
diff --git a/app/helpers/atom_builder_helper.rb b/app/helpers/atom_builder_helper.rb
index 08d70b7ac..484cf0793 100644
--- a/app/helpers/atom_builder_helper.rb
+++ b/app/helpers/atom_builder_helper.rb
@@ -167,6 +167,52 @@ module AtomBuilderHelper
     end
   end
 
+  def include_target(xml, target)
+    simple_id xml, TagManager.instance.uri_for(target)
+
+    if target.object_type == :person
+      include_author xml, target
+    else
+      object_type    xml, target.object_type
+      verb           xml, target.verb
+      title          xml, target.title
+      link_alternate xml, TagManager.instance.url_for(target)
+    end
+
+    # Statuses have content and author
+    return unless target.is_a?(Status)
+
+    rich_content xml, target
+    verb         xml, target.verb
+    published_at xml, target.created_at
+    updated_at   xml, target.updated_at
+
+    author(xml) do
+      include_author xml, target.account
+    end
+
+    if target.reply?
+      in_reply_to xml, TagManager.instance.uri_for(target.thread), TagManager.instance.url_for(target.thread)
+    end
+
+    link_visibility xml, target
+
+    target.mentions.each do |mention|
+      link_mention xml, mention.account
+    end
+
+    target.media_attachments.each do |media|
+      link_enclosure xml, media
+    end
+
+    target.tags.each do |tag|
+      category xml, tag.name
+    end
+
+    category(xml, 'nsfw') if target.sensitive?
+    privacy_scope(xml, target.visibility)
+  end
+
   def include_entry(xml, stream_entry)
     unique_id      xml, stream_entry.created_at, stream_entry.activity_id, stream_entry.activity_type
     published_at   xml, stream_entry.created_at
@@ -185,45 +231,7 @@ module AtomBuilderHelper
 
     if stream_entry.targeted?
       target(xml) do
-        simple_id xml, TagManager.instance.uri_for(stream_entry.target)
-
-        if stream_entry.target.object_type == :person
-          include_author xml, stream_entry.target
-        else
-          object_type    xml, stream_entry.target.object_type
-          verb           xml, stream_entry.target.verb
-          title          xml, stream_entry.target.title
-          link_alternate xml, TagManager.instance.url_for(stream_entry.target)
-        end
-
-        # Statuses have content and author
-        if stream_entry.target.is_a?(Status)
-          rich_content xml, stream_entry.target
-          verb         xml, stream_entry.target.verb
-          published_at xml, stream_entry.target.created_at
-          updated_at   xml, stream_entry.target.updated_at
-
-          author(xml) do
-            include_author xml, stream_entry.target.account
-          end
-
-          link_visibility xml, stream_entry.target
-
-          stream_entry.target.mentions.each do |mention|
-            link_mention xml, mention.account
-          end
-
-          stream_entry.target.media_attachments.each do |media|
-            link_enclosure xml, media
-          end
-
-          stream_entry.target.tags.each do |tag|
-            category xml, tag.name
-          end
-
-          category(xml, 'nsfw') if stream_entry.target.sensitive?
-          privacy_scope(xml, stream_entry.target.visibility)
-        end
+        include_target(xml, stream_entry.target)
       end
     end
 
diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb
index 11585250f..7038bc222 100644
--- a/app/services/favourite_service.rb
+++ b/app/services/favourite_service.rb
@@ -31,14 +31,10 @@ class FavouriteService < BaseService
         end
 
         object_type xml, :activity
-        verb xml, :favourite
+        verb xml, :favorite
 
         target(xml) do
-          author(xml) do
-            include_author xml, favourite.status.account
-          end
-
-          include_entry xml, favourite.status.stream_entry
+          include_target xml, favourite.status
         end
       end
     end.to_xml
diff --git a/app/services/fetch_atom_service.rb b/app/services/fetch_atom_service.rb
index 98ee1db84..f7e9c150a 100644
--- a/app/services/fetch_atom_service.rb
+++ b/app/services/fetch_atom_service.rb
@@ -2,6 +2,8 @@
 
 class FetchAtomService < BaseService
   def call(url)
+    return if url.blank?
+
     response = http_client.head(url)
 
     Rails.logger.debug "Remote status HEAD request returned code #{response.code}"
diff --git a/app/services/unfavourite_service.rb b/app/services/unfavourite_service.rb
index b79b8a938..7ad1778f6 100644
--- a/app/services/unfavourite_service.rb
+++ b/app/services/unfavourite_service.rb
@@ -22,14 +22,10 @@ class UnfavouriteService < BaseService
         end
 
         object_type xml, :activity
-        verb xml, :unfavourite
+        verb xml, :unfavorite
 
         target(xml) do
-          author(xml) do
-            include_author xml, favourite.status.account
-          end
-
-          include_entry xml, favourite.status.stream_entry
+          include_target xml, favourite.status
         end
       end
     end.to_xml
diff --git a/app/workers/after_remote_follow_request_worker.rb b/app/workers/after_remote_follow_request_worker.rb
index ad94d2769..f1d6869cc 100644
--- a/app/workers/after_remote_follow_request_worker.rb
+++ b/app/workers/after_remote_follow_request_worker.rb
@@ -9,7 +9,7 @@ class AfterRemoteFollowRequestWorker
     follow_request  = FollowRequest.find(follow_request_id)
     updated_account = FetchRemoteAccountService.new.call(follow_request.target_account.remote_url)
 
-    return if updated_account.locked?
+    return if updated_account.nil? || updated_account.locked?
 
     follow_request.destroy
     FollowService.new.call(follow_request.account, updated_account.acct)
diff --git a/app/workers/after_remote_follow_worker.rb b/app/workers/after_remote_follow_worker.rb
index 496aaf73e..0d04456a9 100644
--- a/app/workers/after_remote_follow_worker.rb
+++ b/app/workers/after_remote_follow_worker.rb
@@ -9,7 +9,7 @@ class AfterRemoteFollowWorker
     follow          = Follow.find(follow_id)
     updated_account = FetchRemoteAccountService.new.call(follow.target_account.remote_url)
 
-    return unless updated_account.locked?
+    return if updated_account.nil? || !updated_account.locked?
 
     follow.destroy
     FollowService.new.call(follow.account, updated_account.acct)