diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-04 14:43:00 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-04 14:44:16 +0200 |
commit | a289c1d52fa3330ecdfdaeeefdfbddb4b47c9be0 (patch) | |
tree | 9d88056102bf11c1e2ecdcbcd0701c427806c868 | |
parent | 1022d682dc915bcbf3076c0280f29472068830bb (diff) |
Handle delete Salmons, todo: clean up timelines
-rw-r--r-- | app/services/process_feed_service.rb | 2 | ||||
-rw-r--r-- | app/services/process_interaction_service.rb | 12 | ||||
-rw-r--r-- | app/services/remove_status_service.rb | 10 | ||||
-rw-r--r-- | spec/fixtures/push/reblog.atom | 92 |
4 files changed, 115 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 diff --git a/spec/fixtures/push/reblog.atom b/spec/fixtures/push/reblog.atom new file mode 100644 index 000000000..0d7753989 --- /dev/null +++ b/spec/fixtures/push/reblog.atom @@ -0,0 +1,92 @@ +<entry xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:georss="http://www.georss.org/georss" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:media="http://purl.org/syndication/atommedia" xmlns:statusnet="http://status.net/schema/api/1/"> + <id>tag:gs.smuglo.li,2016-09-03:noticeId=661684:objectType=note</id> + <title>dtluna repeated a notice by gargron</title> + <content type="html">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></content> + <link rel="alternate" type="text/html" href="https://gs.smuglo.li/notice/661684"/> + <activity:verb>http://activitystrea.ms/schema/1.0/share</activity:verb> + <published>2016-09-03T13:48:19+00:00</published> + <updated>2016-09-03T13:48:19+00:00</updated> + <author> + <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type> + <uri>https://gs.smuglo.li/user/537</uri> + <name>dtluna</name> + <summary>Sex Goddess of Fediverse. Parabola GNU/Linux-libre user. PGP: 0xA490DBE4 XMPP and email: dtluna@memeware.net</summary> + <link rel="alternate" type="text/html" href="https://gs.smuglo.li/dtluna"/> + <link rel="avatar" type="image/jpeg" media:width="385" media:height="385" href="https://gs.smuglo.li/avatar/537-original-20160807184048.jpeg"/> + <link rel="avatar" type="image/jpeg" media:width="96" media:height="96" href="https://gs.smuglo.li/avatar/537-96-20160807184048.jpeg"/> + <link rel="avatar" type="image/jpeg" media:width="48" media:height="48" href="https://gs.smuglo.li/avatar/537-48-20160807184048.jpeg"/> + <link rel="avatar" type="image/jpeg" media:width="24" media:height="24" href="https://gs.smuglo.li/avatar/537-24-20160807184049.jpeg"/> + <poco:preferredUsername>dtluna</poco:preferredUsername> + <poco:displayName>dtluna</poco:displayName> + <poco:note>Sex Goddess of Fediverse. Parabola GNU/Linux-libre user. PGP: 0xA490DBE4 XMPP and email: dtluna@memeware.net</poco:note> + <poco:address> + <poco:formatted>Minsk, Belarus</poco:formatted> + </poco:address> + <poco:urls> + <poco:type>homepage</poco:type> + <poco:value>https://liberapay.com/dtluna/</poco:value> + <poco:primary>true</poco:primary> + </poco:urls> + <followers url="https://gs.smuglo.li/dtluna/subscribers"></followers> + <statusnet:profile_info local_id="537"></statusnet:profile_info> + </author> + <activity:object> + <activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type> + <id>tag:mastodon.social,2016-09-03:objectId=5984:objectType=Status</id> + <title></title> + <content type="html">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></content> + <link rel="alternate" type="text/html" href="https://mastodon.social/users/Gargron/updates/6066"/> + <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb> + <published>2016-09-03T13:47:59+00:00</published> + <updated>2016-09-03T13:47:59+00:00</updated> + <author> + <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type> + <uri>https://mastodon.social/users/Gargron</uri> + <name>gargron</name> + <summary>Software engineer, free time musician and DIGITAL SPORTS enthusiast. Likes cats. Warning: May contain memes</summary> + <link rel="alternate" type="text/html" href="https://mastodon.social/users/Gargron"/> + <link rel="avatar" type="image/gif" media:width="96" media:height="96" href="https://gs.smuglo.li/avatar/1292-original-20160903122640.gif"/> + <link rel="avatar" type="image/gif" media:width="96" media:height="96" href="https://gs.smuglo.li/avatar/1292-original-20160903122640.gif"/> + <link rel="avatar" type="image/gif" media:width="48" media:height="48" href="https://gs.smuglo.li/avatar/1292-48-20160903122642.gif"/> + <link rel="avatar" type="image/gif" media:width="24" media:height="24" href="https://gs.smuglo.li/avatar/1292-24-20160903122736.gif"/> + <poco:preferredUsername>gargron</poco:preferredUsername> + <poco:displayName>Eugen</poco:displayName> + <poco:note>Software engineer, free time musician and DIGITAL SPORTS enthusiast. Likes cats. Warning: May contain memes</poco:note> + <statusnet:profile_info local_id="1292"></statusnet:profile_info> + </author> + <activity:object> + <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type> + <id>tag:mastodon.social,2016-09-03:objectId=5984:objectType=Status</id> + <title>New note by gargron</title> + <content type="html">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></content> + <link rel="alternate" type="text/html" href="https://mastodon.social/users/Gargron/updates/6066"/> + <status_net notice_id="661682"></status_net> + </activity:object> + <link rel="ostatus:conversation" href="tag:gs.smuglo.li,2016-09-03:objectType=thread:nonce=aec0feafff16e2cf"/> + <ostatus:conversation>tag:gs.smuglo.li,2016-09-03:objectType=thread:nonce=aec0feafff16e2cf</ostatus:conversation> + <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/> + <source> + <id>https://mastodon.social/users/Gargron.atom</id> + <title>Eugen</title> + <link rel="alternate" type="text/html" href="https://mastodon.social/users/Gargron"/> + <link rel="self" type="application/atom+xml" href="https://mastodon.social/users/Gargron.atom"/> + <icon>https://gs.smuglo.li/avatar/1292-original-20160903122640.gif</icon> + <updated>2016-09-04T12:10:44+00:00</updated> + </source> + </activity:object> + <link rel="ostatus:conversation" href="tag:gs.smuglo.li,2016-09-03:objectType=thread:nonce=aec0feafff16e2cf"/> + <ostatus:conversation>tag:gs.smuglo.li,2016-09-03:objectType=thread:nonce=aec0feafff16e2cf</ostatus:conversation> + <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/> + <source> + <id>https://gs.smuglo.li/api/statuses/user_timeline/537.atom</id> + <title>dtluna</title> + <link rel="alternate" type="text/html" href="https://gs.smuglo.li/dtluna"/> + <link rel="self" type="application/atom+xml" href="https://gs.smuglo.li/api/statuses/user_timeline/537.atom"/> + <link rel="license" href="https://creativecommons.org/licenses/by/3.0/"/> + <icon>https://gs.smuglo.li/avatar/537-96-20160807184048.jpeg</icon> + <updated>2016-09-04T01:48:58+00:00</updated> + </source> + <link rel="self" type="application/atom+xml" href="https://gs.smuglo.li/api/statuses/show/661684.atom"/> + <link rel="edit" type="application/atom+xml" href="https://gs.smuglo.li/api/statuses/show/661684.atom"/> + <statusnet:notice_info local_id="661684" source="Qvitter" repeat_of="661682"></statusnet:notice_info> +</entry> |