From a289c1d52fa3330ecdfdaeeefdfbddb4b47c9be0 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 4 Sep 2016 14:43:00 +0200 Subject: [PATCH] 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 +++ spec/fixtures/push/reblog.atom | 92 +++++++++++++++++++++ 4 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 app/services/remove_status_service.rb create mode 100644 spec/fixtures/push/reblog.atom diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index ba11fc4b1f..d14b35e80f 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 b7503ca6ad..536911e2f5 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 0000000000..1b5da6b2ab --- /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 diff --git a/spec/fixtures/push/reblog.atom b/spec/fixtures/push/reblog.atom new file mode 100644 index 0000000000..0d7753989a --- /dev/null +++ b/spec/fixtures/push/reblog.atom @@ -0,0 +1,92 @@ + + tag:gs.smuglo.li,2016-09-03:noticeId=661684:objectType=note + dtluna repeated a notice by gargron + RT @<a href="https://mastodon.social/users/Gargron" class="h-card mention" title="Eugen">gargron</a> Stormbending from Devin Townsend's upcoming album Transcendence is now on YouTube <a href="https://www.youtube.com/watch?v=8s9qh77gj6Y" title="https://www.youtube.com/watch?v=8s9qh77gj6Y" class="attachment thumbnail" id="attachment-122081" rel="nofollow external">https://www.youtube.com/watch?v=8s9qh77gj6Y</a> + + http://activitystrea.ms/schema/1.0/share + 2016-09-03T13:48:19+00:00 + 2016-09-03T13:48:19+00:00 + + http://activitystrea.ms/schema/1.0/person + https://gs.smuglo.li/user/537 + dtluna + Sex Goddess of Fediverse. Parabola GNU/Linux-libre user. PGP: 0xA490DBE4 XMPP and email: dtluna@memeware.net + + + + + + dtluna + dtluna + Sex Goddess of Fediverse. Parabola GNU/Linux-libre user. PGP: 0xA490DBE4 XMPP and email: dtluna@memeware.net + + Minsk, Belarus + + + homepage + https://liberapay.com/dtluna/ + true + + + + + + http://activitystrea.ms/schema/1.0/activity + tag:mastodon.social,2016-09-03:objectId=5984:objectType=Status + + Stormbending from Devin Townsend's upcoming album Transcendence is now on YouTube <a rel="nofollow" href="https://www.youtube.com/watch?v=8s9qh77gj6Y">https://www.youtube.com/watch?v=8s9qh77gj6Y</a> + + http://activitystrea.ms/schema/1.0/post + 2016-09-03T13:47:59+00:00 + 2016-09-03T13:47:59+00:00 + + http://activitystrea.ms/schema/1.0/person + https://mastodon.social/users/Gargron + gargron + Software engineer, free time musician and DIGITAL SPORTS enthusiast. Likes cats. Warning: May contain memes + + + + + + gargron + Eugen + Software engineer, free time musician and DIGITAL SPORTS enthusiast. Likes cats. Warning: May contain memes + + + + http://activitystrea.ms/schema/1.0/note + tag:mastodon.social,2016-09-03:objectId=5984:objectType=Status + New note by gargron + Stormbending from Devin Townsend's upcoming album Transcendence is now on YouTube <a rel="nofollow" href="https://www.youtube.com/watch?v=8s9qh77gj6Y">https://www.youtube.com/watch?v=8s9qh77gj6Y</a> + + + + + tag:gs.smuglo.li,2016-09-03:objectType=thread:nonce=aec0feafff16e2cf + + + https://mastodon.social/users/Gargron.atom + Eugen + + + https://gs.smuglo.li/avatar/1292-original-20160903122640.gif + 2016-09-04T12:10:44+00:00 + + + + tag:gs.smuglo.li,2016-09-03:objectType=thread:nonce=aec0feafff16e2cf + + + https://gs.smuglo.li/api/statuses/user_timeline/537.atom + dtluna + + + + https://gs.smuglo.li/avatar/537-96-20160807184048.jpeg + 2016-09-04T01:48:58+00:00 + + + + +