* Add: `conversations`テーブルに`ancestor_status`プロパティ * Fix test * Fix test more * Add: `limited_visibility`に`Reply`を追加、`context`のURI * Add: 外部からの`context`受信処理 * Fix test * Add: 公開範囲「返信」 * Fix test * Fix: 返信に返信以外の公開範囲を設定できない問題 * Add: ローカル投稿時にメンション追加・他サーバーへの転送 * Fix test * Fix test * Test: ローカルスレッドへの返信投稿の転送 * Test: 未知のアカウントからのメンション * Add: 編集・削除の連合に対応 * Remove: 重複テスト * Fix: 改善 * Add: 編集削除の転送処理・返信なのにsilentなメンションでの通知 * Fix: リプライが第三者に届かない問題 * Add: `always_sign_unsafe` * Add: Subject * Remove space * Fix: 他人のスレッドの送信先一覧を非表示 * Fix: おかしいコード
66 lines
2.1 KiB
Ruby
66 lines
2.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class ActivityPub::Activity::Delete < ActivityPub::Activity
|
|
def perform
|
|
if @account.uri == object_uri
|
|
delete_person
|
|
elsif object_uri == ActivityPub::TagManager::COLLECTIONS[:public]
|
|
delete_friend
|
|
else
|
|
delete_note
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def delete_person
|
|
with_redis_lock("delete_in_progress:#{@account.id}", autorelease: 2.hours, raise_on_failure: false) do
|
|
DeleteAccountService.new.call(@account, reserve_username: false, skip_activitypub: true)
|
|
end
|
|
end
|
|
|
|
def delete_note
|
|
return if object_uri.nil?
|
|
|
|
with_redis_lock("delete_status_in_progress:#{object_uri}", raise_on_failure: false) do
|
|
unless non_matching_uri_hosts?(@account.uri, object_uri)
|
|
# This lock ensures a concurrent `ActivityPub::Activity::Create` either
|
|
# does not create a status at all, or has finished saving it to the
|
|
# database before we try to load it.
|
|
# Without the lock, `delete_later!` could be called after `delete_arrived_first?`
|
|
# and `Status.find` before `Status.create!`
|
|
with_redis_lock("create:#{object_uri}") { delete_later!(object_uri) }
|
|
|
|
Tombstone.find_or_create_by(uri: object_uri, account: @account)
|
|
end
|
|
|
|
@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?
|
|
|
|
return if @status.nil?
|
|
|
|
forwarder.forward! if forwarder.forwardable?
|
|
forward_for_conversation
|
|
delete_now!
|
|
end
|
|
end
|
|
|
|
def forward_for_conversation
|
|
return unless @status.conversation.present? && @status.conversation.local? && @json['signature'].present?
|
|
|
|
ActivityPub::ForwardConversationWorker.perform_async(Oj.dump(@json), @status.id, true)
|
|
end
|
|
|
|
def delete_friend
|
|
friend = FriendDomain.find_by(domain: @account.domain)
|
|
friend&.destroy
|
|
end
|
|
|
|
def forwarder
|
|
@forwarder ||= ActivityPub::Forwarder.new(@account, @json, @status)
|
|
end
|
|
|
|
def delete_now!
|
|
RemoveStatusService.new.call(@status, redraft: false)
|
|
end
|
|
end
|