Skip to content

Commit

Permalink
リファクタリング
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Oct 22, 2023
1 parent 4a3dfc1 commit 59d9462
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions app/workers/activitypub/status_update_distribution_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,27 @@ def perform(status_id, options = {})

protected

def activity
def build_activity(for_misskey: false, for_friend: false)
ActivityPub::ActivityPresenter.new(
id: [ActivityPub::TagManager.instance.uri_for(@status), '#updates/', @status.edited_at.to_i].join,
type: 'Update',
actor: ActivityPub::TagManager.instance.uri_for(@status.account),
published: @status.edited_at,
to: ActivityPub::TagManager.instance.to(@status),
cc: ActivityPub::TagManager.instance.cc(@status),
to: for_friend ? ActivityPub::TagManager.instance.to_for_friend(@status) : ActivityPub::TagManager.instance.to(@status),
cc: for_misskey ? ActivityPub::TagManager.instance.cc_for_misskey : ActivityPub::TagManager.instance.cc(@status),
virtual_object: @status
)
end

def activity
build_activity
end

def activity_for_misskey
ActivityPub::ActivityPresenter.new(
id: [ActivityPub::TagManager.instance.uri_for(@status), '#updates/', @status.edited_at.to_i].join,
type: 'Update',
actor: ActivityPub::TagManager.instance.uri_for(@status.account),
published: @status.edited_at,
to: ActivityPub::TagManager.instance.to(@status),
cc: ActivityPub::TagManager.instance.cc_for_misskey(@status),
virtual_object: @status
)
build_activity(for_misskey: true)
end

def activity_for_friend
ActivityPub::ActivityPresenter.new(
id: [ActivityPub::TagManager.instance.uri_for(@status), '#updates/', @status.edited_at.to_i].join,
type: 'Update',
actor: ActivityPub::TagManager.instance.uri_for(@status.account),
published: @status.edited_at,
to: ActivityPub::TagManager.instance.to_for_friend(@status),
cc: ActivityPub::TagManager.instance.cc(@status),
virtual_object: @status
)
build_activity(for_friend: true)
end
end

0 comments on commit 59d9462

Please sign in to comment.