* Fix mastodon version * テーブル作成 * Wip: フレンドサーバーフォローの承認を受信 * Wip: フレンド申請拒否を受信 * Wip: フォローリクエストを受理 * Wip: 相手からのフォロー・アンフォローを受理 * 普通のフォローとフレンドサーバーのフォローを区別するテストを追加 * ドメインブロックによるフォロー拒否 * ドメインブロックしたあと、申請中のフォロリクを取り下げる処理 * スタブに条件を追加 * Wip: 相手からのDelete信号に対応 * DB定義が消えていたので修正 * Wip: ローカル公開投稿をフレンドに送信する処理など * Wip: 未収載+誰でもの投稿をフレンドに送る設定 * Wip: ローカル公開をそのまま送信する設定を考慮 * Fix test * Wip: 他サーバーからのローカル公開投稿の受け入れ * Wip: Web画面作成 * Fix test * Wip: ローカル公開を連合TLに流す * Wip: フレンドサーバーの削除ボタン * Wip: メール通知や設定のテストなど * Wip: 翻訳を作成 * Fix: 却下されたあとフォローボタンが表示されない問題 * Wip: 編集できない問題 * 有効にしていないフレンドサーバーをリストで無効表示
43 lines
2 KiB
Ruby
43 lines
2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class ActivityPub::ActivityPresenter < ActiveModelSerializers::Model
|
|
attributes :id, :type, :actor, :published, :to, :cc, :virtual_object
|
|
|
|
class << self
|
|
def from_status(status, use_bearcap: true, allow_inlining: true, for_misskey: false, for_friend: false)
|
|
new.tap do |presenter|
|
|
presenter.id = ActivityPub::TagManager.instance.activity_uri_for(status)
|
|
presenter.type = status.reblog? ? 'Announce' : 'Create'
|
|
presenter.actor = ActivityPub::TagManager.instance.uri_for(status.account)
|
|
presenter.published = status.created_at
|
|
presenter.to = for_friend ? ActivityPub::TagManager.instance.to_for_friend(status) : ActivityPub::TagManager.instance.to(status)
|
|
presenter.cc = for_misskey ? ActivityPub::TagManager.instance.cc_for_misskey(status) : ActivityPub::TagManager.instance.cc(status)
|
|
|
|
presenter.virtual_object = begin
|
|
if status.reblog?
|
|
if allow_inlining && status.account == status.proper.account && status.proper.private_visibility? && status.local?
|
|
status.proper
|
|
else
|
|
ActivityPub::TagManager.instance.uri_for(status.proper)
|
|
end
|
|
elsif status.limited_visibility? && use_bearcap && !status.account.user&.setting_unsafe_limited_distribution
|
|
"bear:?#{{ u: ActivityPub::TagManager.instance.uri_for(status.proper), t: status.capability_tokens.first.token }.to_query}"
|
|
else
|
|
status.proper
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
def from_encrypted_message(encrypted_message)
|
|
new.tap do |presenter|
|
|
presenter.id = ActivityPub::TagManager.instance.generate_uri_for(nil)
|
|
presenter.type = 'Create'
|
|
presenter.actor = ActivityPub::TagManager.instance.uri_for(encrypted_message.source_account)
|
|
presenter.published = Time.now.utc
|
|
presenter.to = ActivityPub::TagManager.instance.uri_for(encrypted_message.target_account)
|
|
presenter.virtual_object = encrypted_message
|
|
end
|
|
end
|
|
end
|
|
end
|