Respect "delete" verb on remote feeds
parent
1eb65e2acc
commit
75b3339a99
|
@ -1,2 +1,4 @@
|
||||||
.env
|
.env
|
||||||
.env.*
|
.env.*
|
||||||
|
public/system
|
||||||
|
public/assets
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Status < ActiveRecord::Base
|
||||||
has_one :stream_entry, as: :activity, dependent: :destroy
|
has_one :stream_entry, as: :activity, dependent: :destroy
|
||||||
|
|
||||||
has_many :favourites, inverse_of: :status, 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 :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread
|
||||||
has_many :mentioned_accounts, class_name: 'Mention', dependent: :destroy
|
has_many :mentioned_accounts, class_name: 'Mention', dependent: :destroy
|
||||||
|
|
||||||
|
|
|
@ -16,15 +16,21 @@ class ProcessFeedService < BaseService
|
||||||
|
|
||||||
status = Status.find_by(uri: activity_id(entry))
|
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?
|
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))
|
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)
|
add_reply!(entry, status)
|
||||||
elsif verb(entry) == :share
|
elsif verb(entry) == :share
|
||||||
add_reblog!(entry, status)
|
add_reblog!(entry, status)
|
||||||
else
|
elsif verb(entry) == :post
|
||||||
add_post!(entry, status)
|
add_post!(entry, status)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,6 +77,10 @@ class ProcessFeedService < BaseService
|
||||||
status.save!
|
status.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_post!(status)
|
||||||
|
status.destroy!
|
||||||
|
end
|
||||||
|
|
||||||
def find_original_status(_xml, id)
|
def find_original_status(_xml, id)
|
||||||
return nil if id.nil?
|
return nil if id.nil?
|
||||||
|
|
||||||
|
|
Reference in New Issue