about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-04 14:43:00 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-04 14:44:16 +0200
commita289c1d52fa3330ecdfdaeeefdfbddb4b47c9be0 (patch)
tree9d88056102bf11c1e2ecdcbcd0701c427806c868 /app
parent1022d682dc915bcbf3076c0280f29472068830bb (diff)
Handle delete Salmons, todo: clean up timelines
Diffstat (limited to 'app')
-rw-r--r--app/services/process_feed_service.rb2
-rw-r--r--app/services/process_interaction_service.rb12
-rw-r--r--app/services/remove_status_service.rb10
3 files changed, 23 insertions, 1 deletions
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index ba11fc4b1..d14b35e80 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -91,7 +91,7 @@ class ProcessFeedService < BaseService
   end
 
   def delete_post!(status)
-    status.destroy!
+    RemoveStatusService.new.(status)
   end
 
   def find_original_status(_xml, id)
diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb
index b7503ca6a..536911e2f 100644
--- a/app/services/process_interaction_service.rb
+++ b/app/services/process_interaction_service.rb
@@ -32,6 +32,8 @@ class ProcessInteractionService < BaseService
         add_post!(body, account) if mentions_account?(xml, target_account)
       when :share
         add_post!(body, account) unless status(xml).nil?
+      when :delete
+        delete_post!(xml, account)
       end
     end
   end
@@ -62,6 +64,16 @@ class ProcessInteractionService < BaseService
     account.unfollow!(target_account)
   end
 
+  def delete_post!(xml, account)
+    status = Status.find(activity_id(xml))
+
+    return if status.nil?
+
+    if account.id == status.account_id
+      RemoveStatusService.new.(status)
+    end
+  end
+
   def favourite!(xml, from_account)
     current_status = status(xml)
     current_status.favourites.where(account: from_account).first_or_create!(account: from_account)
diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb
new file mode 100644
index 000000000..1b5da6b2a
--- /dev/null
+++ b/app/services/remove_status_service.rb
@@ -0,0 +1,10 @@
+class RemoveStatusService < BaseService
+  def call(status)
+    status.destroy!
+
+    # TODO
+    # Remove from timelines of self, followers, and mentioned accounts
+    # For remote mentioned accounts, send delete Salmon
+    # Push delete event through ActionCable
+  end
+end