From 75b3339a99bd32c59004effd05dcd0edfc0b7c2a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 16 Mar 2016 10:46:15 +0100 Subject: [PATCH] Respect "delete" verb on remote feeds --- .dockerignore | 2 ++ app/models/status.rb | 2 +- app/services/process_feed_service.rb | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 665da45501..de05776413 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,4 @@ .env .env.* +public/system +public/assets diff --git a/app/models/status.rb b/app/models/status.rb index 52e6f8a212..81744c25eb 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -7,7 +7,7 @@ class Status < ActiveRecord::Base has_one :stream_entry, as: :activity, dependent: :destroy has_many :favourites, inverse_of: :status, dependent: :destroy - has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog + has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog, dependent: :destroy has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread has_many :mentioned_accounts, class_name: 'Mention', dependent: :destroy diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index 7d8563a580..605f615fdf 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -16,15 +16,21 @@ class ProcessFeedService < BaseService status = Status.find_by(uri: activity_id(entry)) + # If we already have a post and the verb is now "delete", we gotta delete it and move on! + if verb(entry) == :delete + delete_post!(status) + next + end + next unless status.nil? status = Status.new(uri: activity_id(entry), url: activity_link(entry), account: account, text: content(entry), created_at: published(entry), updated_at: updated(entry)) - if object_type(entry) == :comment + if object_type(entry) == :comment && verb(entry) == :post add_reply!(entry, status) elsif verb(entry) == :share add_reblog!(entry, status) - else + elsif verb(entry) == :post add_post!(entry, status) end @@ -71,6 +77,10 @@ class ProcessFeedService < BaseService status.save! end + def delete_post!(status) + status.destroy! + end + def find_original_status(_xml, id) return nil if id.nil?