mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-11-01 23:31:13 +01:00
1b5806b744
Using _: property names is discouraged, as in the future, canonicalization may throw an error when encountering that instead of discarding it silently like it does now. We are defining some ActivityStreams properties which we expect to land in ActivityStreams eventually, to ensure that future versions of Mastodon will remain compatible with this even once that happens. Those would be `locked`, `sensitive` and `Hashtag` We are defining a custom context inline for some properties which we do not expect to land in any other context. `atomUri`, `inReplyToAtomUri` and `conversation` are part of the custom defined OStatus context.
45 lines
1 KiB
Ruby
45 lines
1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class ActivityPub::Activity::Delete < ActivityPub::Activity
|
|
def perform
|
|
if @account.uri == object_uri
|
|
delete_person
|
|
else
|
|
delete_note
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def delete_person
|
|
SuspendAccountService.new.call(@account)
|
|
end
|
|
|
|
def delete_note
|
|
status = Status.find_by(uri: object_uri, account: @account)
|
|
status ||= Status.find_by(uri: @object['atomUri'], account: @account) if @object.is_a?(Hash) && @object['atomUri'].present?
|
|
|
|
delete_later!(object_uri)
|
|
|
|
return if status.nil?
|
|
|
|
forward_for_reblogs(status)
|
|
delete_now!(status)
|
|
end
|
|
|
|
def forward_for_reblogs(status)
|
|
return if @json['signature'].blank?
|
|
|
|
ActivityPub::RawDistributionWorker.push_bulk(status.reblogs.includes(:account).references(:account).merge(Account.local).pluck(:account_id)) do |account_id|
|
|
[payload, account_id]
|
|
end
|
|
end
|
|
|
|
def delete_now!(status)
|
|
RemoveStatusService.new.call(status)
|
|
end
|
|
|
|
def payload
|
|
@payload ||= Oj.dump(@json)
|
|
end
|
|
end
|