From a289c1d52fa3330ecdfdaeeefdfbddb4b47c9be0 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 4 Sep 2016 14:43:00 +0200 Subject: Handle delete Salmons, todo: clean up timelines --- app/services/process_feed_service.rb | 2 +- app/services/process_interaction_service.rb | 12 ++++++++++++ app/services/remove_status_service.rb | 10 ++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 app/services/remove_status_service.rb (limited to 'app') 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 -- cgit