Change: #185 『スタンプをつけられた人』ではなく『スタンプをつけた人』のフォロワーにスタンプを転送 (#232)

* Change: #185 『スタンプをつけられた人』ではなく『スタンプをつけた人』のフォロワーにスタンプを転送

* Fix: 絵文字削除が届かない問題

* Test: 送る方にも同じテストを追加
This commit is contained in:
KMY(雪あすか) 2023-11-04 21:27:59 +09:00 committed by GitHub
parent a1d197dfef
commit 24909f9760
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 134 additions and 91 deletions

View file

@ -0,0 +1,41 @@
# frozen_string_literal: true
class ActivityPub::EmojiReactionDistributionWorker < ActivityPub::RawDistributionWorker
# Distribute an emoji reaction to servers that might have a copy of ohagi
def perform(emoji_reaction_id, options = {})
@options = options.with_indifferent_access
@emoji_reaction = EmojiReaction.find(emoji_reaction_id)
@account = @emoji_reaction.account
@status = @emoji_reaction.status
distribute!
rescue ActiveRecord::RecordNotFound
true
end
protected
def payload
@payload ||= Oj.dump(serialize_payload(@emoji_reaction, ActivityPub::EmojiReactionSerializer, signer: @account))
end
def inboxes
@inboxes ||= (@account.followers.inboxes + [@status.account.preferred_inbox_url].compact_blank + relay_inboxes + friend_inboxes).uniq
end
def relay_inboxes
if @status.public_visibility?
Relay.enabled.pluck(:inbox_url)
else
[]
end
end
def friend_inboxes
if @status.distributable_friend?
DeliveryFailureTracker.without_unavailable(FriendDomain.distributables.where(delivery_local: true).where.not(domain: AccountDomainBlock.where(account: @status.account).select(:domain)).pluck(:inbox_url))
else
[]
end
end
end